![]() |
Computer Systems Lab CS1000 |
![]() Wiscinfo |
![]() CS Home |
![]() CSL |
![]() CS1000 |
![]() Feedback |
Command mode allows you to manipulate the contents of your file.There is a command associated with each letter of the alphabet. Very often, these commands are paired as we saw in the discussion of insert mode. A capital letter will make a larger change than the corresponding lower case letter. These commands are summarized in the table below. (the terms ``word'' and ``WORD'' have nonstandard meanings here. A WORD is a larger unit than a word. For example, there are three ``words'' in the string ``semi-simple'' (semi, -, and simple), but there is only one ``WORD''). For many strings however, the two terms will coincide. Other conventions are that <c denotes a single character, <n an integer, and arg is an integer or character argument. to be used with another command. For example, in the sequence cw, w is the argument for the c command. This sequence is used to change a word. Another example of an arg is the sequence ma which marks the current cursor position as point ``a''. Later, typing 'a will move the cursor back to point ``a''. m is the command, a its arg.
Integer arguments are used before commands to execute them multiple times, as in the following examples:
3dd Deletes three consecutive lines starting with the current one.
9x Deletes 9 characters starting with the current one.
5~ Changes the case (from upper to lower or vice versa) of 5 consecutive characters starting with the current one.
8yy Yanks 8 consecutive lines into the buffer starting with the current one.
Vi Movement Commands (command mode) | |||
---|---|---|---|
ctrl-d | move down one screenful | ctrl-u | move up one screenful |
ctrl-f | move down one page | ctrl-b | move up one page |
~ | change case of this character | ctrl-l | refresh the screen |
' | resume previous postion | " | go to beginning of previous line |
0 (zero) | go to first character on current line | $ | go to end of current line |
n | | go to column non current line | % | find matching {( ) or } |
& | repeat most recent substitution command | . | repeat last command |
^ | go to beginning of current line |   |   |
- | move up one line
3- moves up three lines | + | move down one line
3- moves down three lines |
( | back to start of current sentence | ) | forward to next sentence |
{ | back one paragraph | } | forward to next paragraph |
[ | back one section | ] | forward one section |
a | append after cursor | A | append at end of line |
---|---|---|---|
b | move back one word | B | move back one WORD |
c arg | change arg -e.g. cw = change word | C | change the current line |
d arg | delete arg -e.g. dw = delete word | D | delete to end of line |
e | move to end of word | E | move to end of WORD |
f character | find next character after cursor
e.g. "f z" finds the next z on this line | F character | find next previous character |
g | go to start of file (see below *) | nG | go to line n |
h | move left one character | H | beginning of top of line on screen |
i | insert before cursor | I | insert before line |
j | move down one character | J | join this line to line after it |
k | move up one character |   |   |
l | move right one character | L | start of last line on screen |
m character | mark this point with character | M | start middle of line on screen |
n | repeat last /,? command in same dir. | N | repeat last /,? command in opposite dir. |
o | open next line for insert | O | open previous line for insert |
p | put back (buffer) after cursor
e.g. 3dd, a move then p puts back 3 lines | P | put back buffer after cursor |
r character | replace with character | R | replace until you hit esc |
s | replace current character
and ones after until esc | S | replace current line |
t character | to next character on this line
e.g. "ct;" changes to next ";" on this line | T character | to next previous character
dTg deletes to previous g |
u | undo last command | U | undo last command |
w | move forward one word | W | move forward one WORD |
x | delete current character | X | delete previous character |
y arg | yank arg to buffer | Y | yanks lines. Same as yy |
  |   | ZZ | end vi session |