Action | Keys | Notes |
---|---|---|
Down, Up, Left, Right | h, j, k, l | |
Start/end of line | ^/$ | |
Beginning of next word/non-whitespace | w/W | |
End of word/non-whitespace | e/E | |
Move until "x" | tx | |
Find, Reverse-find "x" | fx, Fx | |
Find next | ; | |
Search, Reverse-search "x" | /x, ?x | |
Search next | n | |
Goto line | 12G, :12 | |
Matching brace/bracket | % | R#'s CTRL+ALT+L/R might be better |
All above is relevant in Visual Mode for making selections. E.g. Selecting to matching brace: F{v%.
[z]+modfier scrolls screen Scroll current line to top [zt] Scroll current line to middle [zz]
Enter visual mode [v] Select line [V] Select word [viw] When selecting more than one char, [o] will move the cursor to the beginning/end of the selection. Select "inner"/"around" block (can use "b" or any bracket type of [/], (/), {,}) [vi(] Select quoted string [vi"] (can use any quote marks and supports delete, change etc) Select tag with [t] e.g. [vit] Note "action inner movement" might be better than R#'s CTRL+SHIFT+L/R. Re-select the previous selection when selection is lost [gv]
Insert/Append [i,I,a,A] Change ['visual mode select'c, C, cw, ciw] Replace single [r] OverwRite mode [R] Insert new lines [o, O] Join lines [J, 2J, gJ] Change case [~] Yank [y, Y, yte] store in register x ["xyte] Put [p, P] Delete [x, dte, D] Delete line [dd] Indent/unindent (linewise) [>, <, 3>] Autoindent (one or more lines) [==]
First instance on a line [:s/foo/bar] Whole words only [:s/<foo>/bar Modifiers [g (all instances on line), c (confirm each match) and i (case insensitive)] On all lines [:%s/...] Capture and use backreference by wrapping in (escaped) braces [:s/(foo)/I like \1/g] Similar to PoSh: PS> "Hello world" -replace "(\w+) world", "`$1 everyone" Capture and upper/lowercase backreferences using "\U" and "\L" [:s/(foo)/I like \U\1/g] Ignorecase - what it suggests Smartcase - ignore case if search text is lowercase, otherwise case-sensitive
Edit file [:e[path]] Write buffer [:w[path], :w] Save and exit [:x] Quit [:q, :q!] Load into vertical split [:vsplit [filename]] Move between splits [CTRL+W, [h,j,k,l]]
New buffer [:new] List buffers [:ls] Close current buffer [:bw] Close buffer X [:Xbw] Close buffers X through Y [:X,Ybw] Close buffer by filename [:bw [filename][tab]] Next/previous buffer [:bn]/[:bp] Make current split max width [:CTRL+W, K]
List command history [q:] Write register X (including special registers for '@', '/' and ':') to buffer ["Xp] Yank line back to register X after editing [^v$"Xy] Show relative line numbers [:set relativenumber] Highlight current line [:set cursorline] Highlight current column [:set cursorcolumn]
(nore)n(un)map - Normal mode map (nore)i(un)map - Insert mode map (nore)v(un)map - Visual mode map
Basic repeat [.] Example: [ql/, [ENTER]a[ENTER][ESC]q]
Disabling [CTRL+SHIFT+F12]
Use VsVim to edit, then invoke "Rename refactoring" quickfix.