"h l k j"
- character left, right; line up, down;"b w"
- word/token left, right;"ge e"
- end of word/token left, right;"{ }"
- beginning of previous, next paragraph;"( )"
- beginning of previous, next sentence;"0 gm"
- beginning, middle of line;"^ $"
- first, last character of line;"nG ngg"
- line n, default the last, first;"n%"
- percentage n of the file (n must be provided);"n|"
- column n of current line;"%"
- match of next brace, bracket, comment, #define;"nH nL"
- line n from start, bottom of window;"M"
- middle line of window.<command> <movement>
Examples:
5B
moves back five words,
2w
moves forward two words
i
: insert before cursor
a
: insert after cursor
d[n movement] : delete (~cut)
D : delete to the end of line (equals to d$)
y[n movement] : yank (~copy)
p : put text after the cursor position /put line after current line P : put text before the cursor position / put line before current line (if you put an entire line, th
c[n movement]: change, similar to delete but enters insert mode C : change to the end of line (equals to c$)
[n]r: replace [n] characters with another one R: enter replacement mode
[n]x: delete [n] characters from the cursor [n]X: delete [n] characters before the cursor
[n]s: substitute, apparently just deletes n characters and enter in insert mode.
i,a,c,s: leaves the user in insert mode
[n]~ : change chase of n characters
cc: replace the entire current line dd: delete the entire current line yy: yank a line
. : repeat the last command
--- Movements ---
h,j,k,l: word the cursor left, down, up, right
w: move to the start of the next word W: like w but skips symbols and punctuation b: move to the start of the previous word B: like b but skips symbols and punctuation e: move the the end of the word E: like e but skips symbols and punctuation
G: goto end of file nG: goto line n
Special Positions: $ : end of line 0 : start of line you can repeat a command to the end of line
x : remove a character under the cursor X : remove a character before the cursor
u : undo the last command (vim supports "infinite" undo) U : ?
--- Special Combos ---
'y' and 'p' : copy and paste 'd' and 'p' : cut and paste 'x' and 'p' : swaps two characters
--- Mapping Keys ----
'map seq1 seq2': maps the sequence 1 to the sequence 2 'unmap seq1' : unmap the sequence 1 (if exists)
Example: map ciao dd - in command mode 'ciao' is synonim of 'dd'
VI special sequences are mappable.
--- Splitting ---
'sp'
To search for a pattern, in command mode, append the search pattern to the / character
/pattern
In case of pattern match use "n" to move to the next match and "N" to move to the previous match.
After searching, an empty search pattern will repeat the last search. This works with /, :s, and :g.
So, after searching for a word, use :%s//new/g to change all occurrences to 'new', or :g/ to list all lines containing the word.
In general an uppercase letter means Before, a lowercase one means After
Justify to 75 columns:
set textwidth=75
gqG
Proudly self-hosted on a cheap Raspberry Pi