Given these definitions, there are a number of word-oriented commands.
They are described below:
Command line commands:
- /string/w
- This command searches for `string' occurring as a word. This word
option (w) for a search or a search and replace command
signifies that there is only a match with the search string if
the characters left and right of the match don't belong to the
words in the search string. The search string may contain any
characters so, for example, a search for the string 'one plus
two ' as a word is legal, even with the trailing blank.
- /string1/=/string2/w
- This replaces the word string1 by string2 wherever
string1 occurs as a word.
- =/string2/
- This command replaces the `current word' or the word on which
the cursor is by string2. If the current word occurs
elsewhere,
it will also be replaced, as with the normal replace command.
This command only works for type 1 words.
Key commands:
- Ctrl-W
- `Move to next word'. This command moves the cursor to the first
character of the next word. If there are no more words in the
current line, the search is continued in the next line.
- Ctrl-Q
- `Move to previous word'. This command moves the cursor to the last
character of the previous word. If there are no more words in the
current line, the search continues at the end of the previous line.
- Ctrl-X
- `Delete word forward'. This command deletes all characters
between the current position the cursor and the beginning of the
next word, leaving the cursor on the first character of the next
word. Hence if you want to delete a full word, use this command
with the cursor on the beginning of the word. If the cursor is
not on a word, this command deletes the character the cursor is
on plus all white space till the next word. The delete stops at
a linefeed unless the linefeed is the first character to be
deleted.
- Ctrl-Z or Ctrl-Y
- `Delete word backward'. This command deletes all characters
between the current position of the cursor and the end of the
previous word. Normally the cursor will then be just after the
word previous to the one deleted. If the cursor is not on a
word, the character left of the cursor is deleted and all white
space left of it to the previous word. The delete stops at a
linefeed unless the linefeed is the first character to be
deleted.
- Ctrl-A
- `Jump to the next occurrence of the same word'. With this command
the cursor is moved to the next occurrence of the word under the
cursor.
A fuller explanation of this command is given below.
- Ctrl-B
- This command repeats the last Ctrl-A command. It will also be
explained more fully below.