- Beginner Text Navigation
k- Move up one linej- Move down one lineh- Move left one characterl- Move right one charactere- Move to end of wordb- Move to beginning of word$- Move to end of line0- Move to beginning of lineH- Move to first line of screenM- Move to middle line of screenL- Move to last line of screenw- Move to next wordb- Move to previous word
- Beginner Text Editing
ce- Change rest of current worddw- Delete wordi- InsertI- Insert at start of linea- AppendA- Append at end of lineo- Insert new line belowO- Insert new line abover- Change char and return to cmd modeR- Enter replace modeESC- Go to command mode
- Intermediate Text Navigation I
fw- Move to next 'w' on lineFw- Move to previous 'w' on linetw- Move before next 'w' on lineTw- Move before previous 'w' on line;- Repeat last f, F, t, or T,- Repeat last f, F, t, or T reversed5j- Move down 5 lines5k- Move up 5 lines
- Intermediate Text Navigation II
5w- Move 5 words forward5b- Move 5 words backwardctrl+e- Scroll downctrl+y- Scroll upgg- Go to beginning of fileG- Go to end of file12G- Go to line 12ctrl+f- Move forward one screenctrl+b- Move backward one screen
- Intermediate Text Editing I
yy- Yank (copy) liney$- Yank (copy) to end of lineye- Yank (copy) to end of worddd- Delete (cut) current line5dd- Delete 5 linesd2w- Delete (cut) next two wordsD- Delete (cut) to end of line (one char)p- Paste
- Intermediate Text Editing II
P- Paste before cursoru- UndoU- Undo all changes to current linectrl+r- Redo.- Repeat last change5.- Repeat last change 5 timesde- Delete (cut) to end of wordd$- Delete (cut) to end of line
- Advanced Text Navigation
^- Move to first non whitespace char20|- Go to column 20%- Go to matching parenthesis or bracketctrl+o- Move to older positionctrl+i- Move to newer positionzt- Scroll current line to top of window
- Visual Mode
:w filename↵- Write selection to 'filename'v- Visual mode select charactersV- Visual mode highlight lines~- Swap case>- Shift right<- Shift leftc- Change highlighted texty- Yank (copy) highlighted textd- Cut highlighted text=- Re-indent selection
- Window Management
:e filename↵- Set current buffer to 'filename':sp↵- New window above:vs↵- New window to left:q↵- Close current window:qa↵- Close all windows
- File Management
:q!↵- Quit without saving:wq↵- Save and exit:x↵- Save and exit if modified:r filename↵- Read and insert 'filename':r !cmd↵- Execute and insert results of 'cmd':!rm filename↵- Delete 'filename':e↵- Open new filectrl+g- Show file infoga- Show character info:w↵- Save changes:q↵- Quit
- Bookmarks
:marks↵- Show bookmarksma- Mark position 'a'`a- Go to bookmark position 'a'``- Go to previous position
- Replace
:s/foo/bar↵- Replace first 'foo' with 'bar' on line:s/foo/bar/g↵- Replace all 'foo' with 'bar' on line:%s/foo/bar/g↵- Replace all 'foo' with 'bar' in file:%s/foo/bar↵- Replace first 'foo' with 'bar' on every line:s/foo/bar/gc↵- Confirm replace all 'foo' with 'bar' on line:s/foo/bar/i↵- Ignore case replace first 'foo' with 'bar'rx- Replace current char with 'x':%s/foo/bar/gc↵- Confirm replace all 'foo' with 'bar' in file:2,9s/foo/bar/g↵- Replace all 'foo' with 'bar' between lines 2 and 9
- Search
/foo↵- Search forwards for 'foo'?foo↵- Search backwards for 'foo'n- Search nextN- Search previous*- Search for current word forward:set nois↵- Turn off incremental search:set ic↵- Set ignore case:set is↵- Set incremental search:set hls↵- Set highlight matching phrases
- Misc
vim -t foo↵- Start editing where foo is defined:help cmd↵- Lookup 'cmd' in help:make↵- Run make:!ls↵- Execute 'ls' commandctrl+p- Move autocomplete backwardctrl+x- Move language autocomplete forwardctrl+o- Move language autocomplete backwardK- Look up word in man pagesyw- Yank to beginning of next word
Last active
June 16, 2016 19:33
-
-
Save michaelmagistro/03bfbb02e3c311d90f01 to your computer and use it in GitHub Desktop.
Vim cheatsheet
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment