This cheat sheet provides a concise summary of common Vim commands for global commands, editing, macros, working with multiple files, cursor movement, marking/cutting text, indentation, and folding. It covers the essential commands for navigating and editing documents, running macros, splitting windows, switching buffers, and more in 3 sentences or less.
This cheat sheet provides a concise summary of common Vim commands for global commands, editing, macros, working with multiple files, cursor movement, marking/cutting text, indentation, and folding. It covers the essential commands for navigating and editing documents, running macros, splitting windows, switching buffers, and more in 3 sentences or less.
This cheat sheet provides a concise summary of common Vim commands for global commands, editing, macros, working with multiple files, cursor movement, marking/cutting text, indentation, and folding. It covers the essential commands for navigating and editing documents, running macros, splitting windows, switching buffers, and more in 3 sentences or less.
This cheat sheet provides a concise summary of common Vim commands for global commands, editing, macros, working with multiple files, cursor movement, marking/cutting text, indentation, and folding. It covers the essential commands for navigating and editing documents, running macros, splitting windows, switching buffers, and more in 3 sentences or less.
The document outlines many keyboard shortcuts for navigating and editing text in the vim text editor. Some of the key takeaways are commands for cursor movement, jumping between lines/files/buffers, editing text, cutting/pasting, searching/replacing text, indentation and exiting vim.
Some ways to navigate between lines/files/buffers in vim include using keyboard shortcuts like h, j, k, l to move the cursor; gg, G to go to the first/last line; :e file to edit a new file; :bn and :bp to go to the next/previous buffer; :b file to go to a buffer by file name.
Common editing commands in vim include r to replace a single character, i to insert before the cursor, a to insert after the cursor, dd to delete a line, yw to yank/copy a word, p to paste clipboard text, u to undo and . to repeat the last command.
Please consider sponsoring this project!
Vim Cheat Sheet
Global Editing Macros Working with multiple files :h[elp] keyword - open r - replace a single character. qa - record macro a :e[dit] file - edit a file in a new buffer help for keyword R - replace more than one q - stop recording macro :bn[ext] - go to the next buffer :sav[eas] file - save file character, until ESC is pressed. as @a - run macro a :bp[revious] - go to the previous buffer J - join line below to the :clo[se] - close current current one with one space in @@ - rerun last run macro :bd[elete] - delete a buffer (close a file) pane between Cut and paste :b[uffer]# - go to a buffer by index # :ter[minal] - open a gJ - join line below to the terminal window current one without space in yy - yank (copy) a line :b[uffer] file - go to a buffer by file between K - open man page for word 2yy - yank (copy) 2 lines :ls or :buffers - list all open buffers under the cursor gwip - reflow paragraph yw - yank (copy) the characters :sp[lit] file - open a file in a new buffer and split Cursor movement g~ - switch case up to motion of the word from the cursor window position to the start of the next h - move cursor left word :vs[plit] file - open a file in a new buffer and gu - change to lowercase up to motion vertically split window j - move cursor down yiw - yank (copy) word under gU - change to uppercase up to the cursor :vert[ical] ba[ll] - edit all buffers as vertical k - move cursor up motion windows yaw - yank (copy) word under l - move cursor right cc - change (replace) entire the cursor and the space after :tab ba[ll] - edit all buffers as tabs line or before it H - move to top of screen Ctrl + ws - split window C - change (replace) to the end y$ - yank (copy) to end of line M - move to middle of screen of the line Ctrl + wv - split window vertically p - put (paste) the clipboard L - move to bottom of screen c$ - change (replace) to the after cursor Ctrl + ww - switch windows end of the line w - jump forwards to the start P - put (paste) before cursor Ctrl + wq - quit a window of a word ciw - change (replace) entire word gp - put (paste) the clipboard Ctrl + wx - exchange current window with next one W - jump forwards to the start after cursor and leave cursor of a word (words can contain cw or ce - change (replace) to after the new text Ctrl + w= - make all windows equal height & width punctuation) the end of the word gP - put (paste) before cursor Ctrl + wh - move cursor to the left window (vertical split) e - jump forwards to the end of s - delete character and and leave cursor after the new a word text substitute text Ctrl + wl - move cursor to the right window (vertical dd - delete (cut) a line split) E - jump forwards to the end of S - delete line and substitute a word (words can contain text (same as cc) Ctrl + wj - move cursor to the window below (horizontal punctuation) 2dd - delete (cut) 2 lines split) xp - transpose two letters b - jump backwards to the start (delete and paste) dw - delete (cut) the characters of a word of the word from the cursor Ctrl + wk - move cursor to the window above (horizontal position to the start of the next split) u - undo B - jump backwards to the start word of a word (words can contain Ctrl + wH - make current window full height at far left U - restore (undo) last changed diw - delete (cut) word under (leftmost vertical window) punctuation) line the cursor ge - jump backwards to the Ctrl + wL - make current window full height at far right Ctrl + r - redo (rightmost vertical window) end of a word daw - delete (cut) word under the cursor and the space after gE - jump backwards to the . - repeat last command or before it Ctrl + wJ - make current window full width at the very end of a word (words can bottom (bottommost horizontal window) contain punctuation) Marking text (visual mode) D - delete (cut) to the end of the line Ctrl + wK - make current window full width at the very v - start visual mode, mark top (topmost horizontal window) % - move to matching character lines, then do a command (like (default supported pairs: '()', y-yank) d$ - delete (cut) to the end of '{}', '[]' - use :h matchpairs in the line Diff vim for more info) V - start linewise visual mode zf - manually define a fold up to motion x - delete (cut) character 0 - jump to the start of the line o - move to other end of zd - delete fold under the cursor marked area Indent text ^ - jump to the first non-blank za - toggle fold under the cursor character of the line Ctrl + v - start visual block >> - indent (move right) line one shiftwidth mode zo - open fold under the cursor $ - jump to the end of the line O - move to other corner of << - de-indent (move left) line one shiftwidth zc - close fold under the cursor g_ - jump to the last non-blank block character of the line zr - reduce (open) all folds by one level aw - mark a word >% - indent a block with () or {} gg - go to the first line of the (cursor on brace) zm - fold more (close) all folds by one level document ab - a block with () >ib - indent inner block with G - go to the last line of the () zi - toggle folding functionality aB - a block with {} document ]c - jump to start of next change at - a block with <> tags 5gg or 5G - go to line 5 ib - inner block with () >at - indent a block with <> [c - jump to start of previous change tags gd - move to local declaration iB - inner block with {} do or :diffg[et] - obtain (get) difference (from other 3== - re-indent 3 lines buffer) gD - move to global declaration it - inner block with <> tags =% - re-indent a block with () dp or :diffpu[t] - put difference (to other buffer) fx - jump to next occurrence Esc - exit visual mode or {} (cursor on brace) of character x :diffthis - make current window part of diff =iB - re-indent inner block Visual commands tx - jump to before next with {} :dif[fupdate] - update differences occurrence of character x > - shift text right gg=G - re-indent entire buffer :diffo[ff] - switch off diff mode for current window Fx - jump to previous < - shift text left occurence of character x ]p - paste and adjust indent to y - yank (copy) marked text current line Tx - jump to after previous occurence of character x d - delete marked text Exiting
; - repeat previous f, t, F or T ~ - switch case :w - write (save) the file, but
movement don't exit u - change marked text to , - repeat previous f, t, F or T lowercase :w !sudo tee % - write movement, backwards out the current file using sudo U - change marked text to } - jump to next paragraph (or uppercase :wq or :x or ZZ - write (save) function/block, when editing and quit code) Registers :q - quit (fails if there are { - jump to previous paragraph :reg[isters] - show unsaved changes) (or function/block, when registers content editing code) :q! or ZQ - quit and throw "xy - yank into register x away unsaved changes zz - center cursor on screen "xp - paste contents of register :wqa - write (save) and quit Ctrl + e - move screen down x on all tabs one line (without moving cursor) "+y - yank into the system Search and replace clipboard register Ctrl + y - move screen up /pattern - search for "+p - paste from the system pattern one line (without moving cursor) clipboard register ?pattern - search backward Ctrl + b - move back one full Marks and positions for pattern screen :marks - list of marks \vpattern - 'very magic' Ctrl + f - move forward one pattern: non-alphanumeric full screen ma - set current position for characters are interpreted as mark A special regex symbols (no Ctrl + d - move forward 1/2 a escaping needed) screen `a - jump to position of mark A n - repeat search in same Ctrl + u - move back 1/2 a direction screen y`a - yank text to position of mark A N - repeat search in opposite direction Insert mode - inserting/appending text `0 - go to the position where Vim was previously exited :%s/old/new/g - replace i - insert before the cursor all old with new throughout file `" - go to the position when I - insert at the beginning of last editing this file :%s/old/new/gc - replace the line all old with new throughout file `. - go to the position of the with confirmations a - insert (append) after the last change in this file cursor :noh[lsearch] - remove `` - go to the position before highlighting of search matches A - insert (append) at the end the last jump of the line Search in multiple files :ju[mps] - list of jumps :vim[grep] /pattern/ o - append (open) a new line below the current line Ctrl + i - go to newer {`{file}`} - search for position in jump list pattern in multiple files O - append (open) a new line above the current line Ctrl + o - go to older position in jump list :cn[ext] - jump to the next ea - insert (append) at the end match of the word :changes - list of changes :cp[revious] - jump to the Ctrl + h - delete the previous match g, - go to newer position in character before the cursor change list during insert mode :cope[n] - open a window containing the list of matches g; - go to older position in Ctrl + w - delete word before change list the cursor during insert mode :ccl[ose] - close the Ctrl + ] - jump to the tag quickfix window Ctrl + j - begin new line under cursor during insert mode Tabs :tabnew or :tabnew Ctrl + t - indent (move right) line one shiftwidth during {page.words.file} - open a file in a new tab insert mode Ctrl + wT - move the current Ctrl + d - de-indent (move split window into its own tab left) line one shiftwidth during insert mode gt or :tabn[ext] - move to the next tab Ctrl + n - insert (auto- complete) next match before gT or :tabp[revious] - the cursor during insert mode move to the previous tab
Ctrl + p - insert (auto- #gt - move to tab number #
complete) previous match before the cursor during insert :tabm[ove] # - move mode current tab to the #th position (indexed from 0) Ctrl + rx - insert the contents of register x :tabc[lose] - close the current tab and all its windows Ctrl + ox - Temporarily enter normal mode to issue one :tabo[nly] - close all tabs normal-mode command x. except for the current one
Esc - exit insert mode :tabdo command - run the
command on all tabs (e.g. :tabdo q - closes all opened tabs)