Deleting a block of text, Moving and copying blocks of text, Customizing your environment – HP NonStop G-Series User Manual

Page 164: Saving your customizations, Selected vi environment variables, Customizing

Advertising
background image

:1,3w my.new.file<Return>

Deleting a Block of Text

The delete command in ex is d, just as in vi. To delete from the current line to the end of the file,
use the following command:

:.,$d<Return>

Moving and Copying Blocks of Text

The ex command d saves the deleted text to the same paste buffer as the vi command. You can
also use the ex copy command ya (for yank) and the paste command pu (for put) to copy and
paste text.

Customizing Your Environment

The ex editor provides two mechanisms for customizing your vi environment. You can use the
:set

command to set environment variables and the :map command to map a key sequence to

a vi command key.
Environment variables can be assigned either option or nooption (for Boolean variables) or
option=value

. The full set of environment variables is described in the ex(1) reference page

either online or in the Open System Services Shell and Utilities Reference Manual.

Table 27

lists

some of the environment variables.

Table 27 Selected vi Environment Variables

Description

Variable

Specifies that when an error occurs, a bell sounds. This is the default setting.

errorbells

Specifies that when searches are performed, the case of characters should be ignored. The
default setting is noignorecase.

ignorecase

Specifies that line numbers are to be displayed at the left margin. The default setting is
nonumber

.

number

Specifies that when you type a matching parenthesis or brace, the cursor moves to the
matching character and then returns. The default setting is noshowmatch.

showmatch

Specifies the amount of space between tab stops. The default setting is eight spaces.

tabstop

Try displaying the line numbers of your example file by entering the following command:

:set number<Return>

Remove the line numbers by entering:

:set nonumber<Return>

The :map command sets a single vi command key to a vi command sequence. The syntax for
the :map command is:

:map key sequence<Return>

This command sequence replaces any existing command for that key. The command sequence
should be identical to the keystrokes you want to map, except that special keys such as Return,
Esc, and keys modified with Ctrl must be preceded by Ctrl-V. Because the q and v keys do not
have commands associated with them, they are good keys to map.
For example, to map a key sequence that inserts a line into your text that says “This space held
for new text”, you could use the following command:

:map q oThis space held for new text<Ctrl-V><Esc><Return>

Note the use of Ctrl-V preceding the Esc character.

Saving Your Customizations

You can make your environment customizations permanent by placing the appropriate ex commands
in a file named .exrc in your home directory. Commands placed in this file take effect every time

164 The vi Editor

Advertising
This manual is related to the following products: