This manual is copied from here and has been modified by me.
default values | 1 |
---|
<*> | * must not be taken literally. |
[*] | * is optional. |
^X | <ctrl>X |
<sp> | space |
<cr> | carriage return |
<lf> | line feed |
<ht> | horizontal tab |
<esc> | escape |
<erase> | your erase character. |
<kill> | your kill character. |
<intr> | your interrupt character. |
<a-z> | an element in the range [a...z] . |
N | Whether a number, N , can be prefixed ✔ to the command or not ❌. |
CHAR | char unequal to <ht> or <sp> |
WORD | word followed by <ht> , <sp> , or <lf> . |
N | Command | Meaning |
---|
✔ | h , ^H , <erase> | Move N characters to the left. |
✔ | j , <lf> , N | N lines downward. |
✔ | l , <sp> | N chars to the right. |
✔ | k , P | N lines upward. |
✔ | $ | To the end of line N from the cursor. |
❌ | ^ | To the first CHAR of the line. |
✔ | _ | To the first CHAR N - 1 lines lower. |
✔ | - | To the first CHAR N lines higher. |
✔ | + , <cr> | To the first CHAR N lines lower. |
❌ | 0 | To the first char of the line. |
✔ | | | To column N (<ht> : only to the endpoint). |
✔ | f<char> | N <char> s to the right (find). |
✔ | t<char> | Till before N <char> s to the right. |
✔ | F<char> | N <char> s to the left. |
✔ | T<char> | Till after N <char> s to the left. |
✔ | ; | Repeat latest ‘f’ |
✔ | , | Idem in opposite direction. |
✔ | w | N words forward. |
✔ | W | N WORDS forward. |
✔ | b | N words backward. |
✔ | B | N WORDS backward. |
✔ | e | To the end of word N forward. |
✔ | E | To the end of WORD N forward. |
✔ | G | Go to line N (default EOF). |
✔ | H | To line N from top of the screen (home). |
✔ | L | To line N from bottom of the screen (last). |
❌ | M | To the middle line of the screen. |
❌ | ) | N sentences forward. |
✔ | ( | N sentences backward. |
✔ | } | N paragraphs forward. |
✔ | { | N paragraphs backward. |
❌ | ]] | To the next section (default EOF). |
❌ | [[ | To the previous section (default begin of file). |
❌ | `<a-z> | To the mark. |
❌ | '<a-z> | To the first CHAR of the line with the mark. |
❌ | `` | To the cursor position before the latest absolute jump (of which are examples ‘/’ and ‘G’). |
❌ | '' | To the first CHAR of the line on which the cursor was placed before the latest absolute jump. |
❌ | /<string> | To the next occurrence of <string> . |
❌ | ?<string> | To the previous occurrence of <string> . |
❌ | n | Repeat latest / or ? (next). |
❌ | N | Idem in opposite direction. |
❌ | % | Find the next bracket and go to its match (also with { or } and [ or ] ). |
Command | Meaning |
---|
:ta <name> | Search in the tags file[s] where <name> is defined (file, line) and go to it. |
^] | Use the name under the cursor in a :ta command. |
^T | Pop the previous tag off the tagstack and return to its position. |
:[x,y]g/<string>/<cmd> | Search globally [from line x to y ] for <string> and execute the ‘ex’ <cmd> on each occurrence. |
:[x,y]v/<string>/<cmd> | Execute <cmd> on the lines that don’t match. |
Command | Meaning |
---|
u | Undo the latest change. |
U | Undo all changes on a line, while not having moved off of it. |
:q! | Quit vi without writing. (Meaning your changes won’t be saved) |
:e! | Re-edit a messed up file. |
These take you into input mode, hit <esc>
to reenter command mode.
N | Command | Meaning |
---|
✔ | a | N times after the cursor. |
✔ | A | N times at the end of line. |
✔ | i | N times before the cursor (insert) . |
✔ | I | N times before the first CHAR of the line. |
✔ | o | On a new line below the current (open). |
✔ | O | On a new line above the current. |
✔ | ><move> | Shift lines N shiftwidths to the right, where <move> is a move command |
✔ | >> | Shift N lines down, one shiftwidth to the right. |
✔ | ["<a-zA-Z1-9>]p | Put the contents of the (default undo) buffer N times after the cursor. A buffer containing lines is put only once, below the current line. |
✔ | ["<a-zA-Z1-9>]P | Put the contents of the (default undo) buffer N times before the cursor. A buffer containing lines is put only once, above the current line. |
✔ | . | Repeat previous command N times. If the last command before a . command references a numbered buffer, the buffer number is incremented first (and the count is ignored): |
Everything deleted can be stored into a buffer. This is achieved by putting a "
and a lowercase letter a-z
before the delete command.
The deleted text will be in the buffer with the used letter. If capital A-Z
is used as the buffer name, the conjugate buffer, lowercase a-z
will be appended instead of overwritten with the text. The undo buffer always contains the latest change.
Buffers 1-9 contain the latest 9 LINE deletions, where "1
is the most recent.
N | Command | Meaning |
---|
✔ | x | Delete N chars under and after the cursor. |
✔ | X | Delete N chars before the cursor. |
✔ | d<move> | Delete N times in the direction of the <move> . |
✔ | dd | N lines. |
❌ | D | The rest of the line. |
✔ | <<move> | Shift lines N shiftwidths to the left, where <move> is a move command |
✔ | << | Shift N lines down one shiftwidth to the left. |
✔ | . | Repeat latest command N times. |
These take you into input mode, hit <esc>
to reenter command mode.
N | Command | Meaning |
---|
✔ | r<char> | Replace N chars by <char> - no <esc> . |
✔ | R | Overwrite the rest of the line, appending change N - 1 times. |
✔ | s | Substitute N chars. |
✔ | S | Substitute N lines. |
✔ | c<move> | Change from begin to endpoint of N<move> . |
✔ | cc | Change N lines. |
✔ | C | The rest of the line and N - 1 next lines. |
✔ | =<move> | If the option ‘lisp’ is set, this command will realign the lines described by N<move> as though they had been typed with the option ‘ai’ set too. |
❌ | ~ | Switch lower and upper cases (should be an operator, like c ). |
✔ | J | Join N lines (default 2). |
✔ | . | Repeat latest command N times (‘J’ only once). |
❌ | & | Repeat latest ‘ex’ substitute command, e.g. ‘:s/wrong/good’. |
❌ | :[x,y]s/<p>/<r>/<f> | Substitute (on lines x through y) the pattern <p> (default the last pattern) with <r> . Useful flags <f> are ‘g’ for ‘global’ (i.e. change every non-overlapping occurrence of <p> ) and ‘c’ for ‘confirm’ (type ‘y’ to confirm a particular substitution, else <cr> ). Instead of ‘/’ any punctuation CHAR unequal to <lf> can be used as delimiter. |
The basic meta-characters for the replacement pattern are ‘&’ and ‘~‘; these are given as ‘&’ and ‘~’ when nomagic is set.
Each instance of ‘&’ is replaced by the characters which the regular expression matched.
The meta-character ‘~’ stands, in the replacement pattern, for the defining text of the previous replacement pattern.
Other meta-sequences possible in the replacement pattern are always introduced by the escaping character ‘\‘.
The sequence ‘\n’ (with ‘n’ in [1-9]) is replaced by the text matched by the n-th regular subexpression enclosed between
‘(’ and ‘)’. The sequences ‘\u’ and ‘\l’ cause the immediately following character in the replacement to be
converted to upper- or lower-case respectively if this character is a letter. The sequences ‘\U’ and ‘\L’ turn such
conversion on, either until ‘\E’ or ‘\e’ is encountered, or until the end of the replacement pattern.
With yank commands you can put "<a-zA-Z>
before the command, just as with delete commands.
Otherwise you only copy to the undo buffer. The use of buffers <a-z>
is the way of copying text to another file;
see the :e <file>
command.
N | Command | Meaning |
---|
✔ | y<move> | Yank from begin to endpoint of N<move> . |
✔ | yy | N lines. |
✔ | Y | Idem (should be equivalent to y$ though). |
❌ | m<a-z> | Mark the cursor position with a letter. |
Command | Meaning |
---|
^@ | If typed as the first character of the insertion, it is replaced with the previous text inserted (max. 128 chars), after which the insertion is terminated. |
^V | Deprive the next char of its special meaning (e.g. <esc> ). |
^D | One shiftwidth to the left, but only if nothing else has been typed on the line. |
0^ | Remove all indentation on the current line (there must be no other chars on the line). |
^^ | Idem, but it is restored on the next line. |
^T | One shiftwidth to the right, but only if nothing else has been typed on the line. |
^H or <erase> | One char back. |
^W | One word back. |
<kill> | Back to the beginning of the change on the current line. |
<intr> | Like <esc> (but you get a beep as well). |