Skip to content

Instantly share code, notes, and snippets.

@stunko
Last active August 29, 2015 14:14
Show Gist options
  • Save stunko/3f565b5d221b003b3f7e to your computer and use it in GitHub Desktop.
Save stunko/3f565b5d221b003b3f7e to your computer and use it in GitHub Desktop.
Vim help. Command list
Move cursor down one line j Basic
Move cursor up one line k Basic
Move cursor left one character h Basic
Move cursor right one character l Basic
Return to Normal mode <ESC>
(escape) Basic
Exit the editor, discarding any changes :q!<ENTER> Basic
Exit the editor, but abort if there are unsaved changes :q<ENTER> Basic
Delete the character under the cursor x Basic
Insert text before the cursor i Basic
Append text at the end of the current line A Basic
Save the current file and exit :wq<ENTER> Basic
Append text after the cursor a Basic
Invert case of current character ~ Beginner
Go down half a screen <C-D> Beginner
Go up half a screen <C-U> Beginner
Go forward a screen <C-F> Beginner
Go back a screen <C-B> Beginner
Go to end of text G Beginner
Go to previous word b Beginner
Go to next word w Beginner
Go to end of (next) word e
(goes to end of next word if already at end of word) Beginner
Go to end of previous word ge Beginner
Go to first non-whitespace character of current line ^ Beginner
Go to last character of current line $ Beginner
Go to line n nG ngg Beginner
Go to first line of file 1G gg Beginner
Go to last line of file G Beginner
Insert at beginning of line (after whitespace) I Basic
Undo last command u Beginner
Restore last changed line U Beginner
Redo last undo <C-R> Beginner
Move cursor left to start of next space-separated word B Beginner
Move cursor right to start of next space-separated word W Beginner
Move cursor left to end of next space-separated word gE Beginner
Move cursor right to end of next space-separated word E Beginner
Move cursor to next occurrence of character c fc Beginner
Move cursor to previous occurrence of character c Fc Beginner
Move cursor to character before next occurrence of c tc Beginner
ove cursor to character after previous occurrence of c Tc Beginner
Delete a word dw Beginner
Delete to the end of the line d$ Beginner
Delete text indicated by motion m dm
(example: d$ means delete to end of line) Beginner
Delete n words ndw Beginner
Move to the start of the line (before whitespace) 0 Beginner
Delete a line dd Beginner
Undo the last command u
(may be used repeatedly to undo multiple commands) Beginner
Redo the last undone command <C-R>
(Control-R) Beginner
Put previously deleted (or copied) text after the cursor p Beginner
Put previously deleted text before the cursor P Beginner
Replace the character under the cursor with character x rx Beginner
Change to the end of the current word ce Beginner
Change to the end of the current line c$ Beginner
See location in file and file status <C-G>
(Control-G) Beginner
Search for phrase /phrase<ENTER> Beginner
Substitute first occurrence of phrase1 with phrase2 on the current line :s/phrase1/phrase2<ENTER> Beginner
Substitute all occurrences of phrase1 with phrase2 on the current line :s/phrase1/phrase2/g<ENTER>
(The /g at the end means "global") Beginner
Substitute all occurrences of phrase1 with phrase2 in the entire file :%s/phrase1/phrase2/g
(% means execute the command for the entire file) Beginner
Execute external command cmd :!cmd Beginner
Save the current file to file named filename :w filename Beginner
Save the visually selected area to file named filename :w filename
(vim will automatically add '<,'> to the beginning of your command for the visually selected area) Beginner
Open a new line below the cursor's line and enter Insert mode o Beginner
Open a new line above the cursor's line and enter Insert mode O (capital o) Beginner
Enter Replace mode, to repeatedly replace the character under the cursor and advance R Beginner
Yank (copy) the selected text y Beginner
Yank (copy) the current line yy or Y Beginner
Yank (copy) from cursor through motion m ym Beginner
Put (paste) copied text after the cursor p Beginner
Put (paste) copied text before the cursor P Beginner
Ignore case in searches :set ic (or :set ignorecase) Beginner
Show partial matches while typing search phrase :set is (or :set incsearch) Beginner
Highlight all matching phrases for the last search :set hls (or :set hlsearch) Beginner
Get help on command cmd :help cmd Beginner
Jump to the next window <C-W><C-W> Beginner
ark this line x mx Intermediate
Go to exact position of mark in line marked x `x Intermediate
Go to percentage from top of file n% Intermediate
Match of next brace, bracket, comment, #define % Intermediate
Go to line n from top of window nH Intermediate
Go to line n from bottom of window nL Intermediate
Insert at first column gI Intermediate
Go to line marked x 'x Intermediate
Switch case for movement command m g~m Intermediate
Lowercase text between cursor and movement m gum Intermediate
Uppercase text between cursor and movement command m gUm Intermediate
Delete range r lines :rd<Enter> Intermediate
Delete range r lines into register x :rdx<Enter> Intermediate
Insert character represented by ASCII value n (Insert mode) <C-V>n Intermediate
Insert previously inserted text (Insert mode) <C-A> Intermediate
Text completion before cursor (Insert mode) <C-N> Intermediate
Text completion after cursor (Insert mode) <C-P> Intermediate
Delete word before cursor (Insert mode) <C-W> Intermediate
Delete all inserted characters in current line <C-U> Intermediate
Show the content of all registers :reg<Enter> Intermediate
Show the content of register x :reg x<Enter> Intermediate
Perform rot13 encoding on movement m g?m Intermediate
Filter lines of movement m through command c !mc Intermediate
Filter n lines through command c n!!c Intermediate
Filter range r lines through command c :r!c Intermediate
In visual mode, exchange cursor position with start/end of highlighting o Intermediate
Start highlighting block <C-V> Intermediate
Start highlighting with previous visual area gv Intermediate
Record typed commands to register x qx Intermediate
Append typed commands to register x qX Intermediate
Stop recording q Intermediate
Move cursor to leftmost position of screen on current line g0 Intermediate
Move cursor to first non-blank character of current line on screen g^ Intermediate
Move cursor to last character of current line on screen g$ Intermediate
Move cursor one screen line up gk Intermediate
Move cursor one screen line down gj Intermediate
Repeat last f/F/t/T movement ; Intermediate
Inverse of last f/F/t/T movement , (comma) Intermediate
Set a mark in the current file m[a-z] Intermediate
Set a mark that can be returned to from any file m[A-Z]
(capital letters) Intermediate
Jump to tag under cursor <C-]> Intermediate
Return from tag jump <C-T> Intermediate
Jump to tag on top of tag stack (or select if multiple matches) :tj Intermediate
Scroll one line up <C-E> Intermediate
Scroll one line down <C-Y> Intermediate
Scroll current line to top of window zt or z<Enter> Intermediate
Scroll current line to center of window zz or z. Intermediate
Scroll current line to bottom of window zb or z- Intermediate
Scroll one character to the right zh Intermediate
Scroll one character to the left zl Intermediate
Scroll half a screen to the right zH Intermediate
Scroll half a screen to the left zL Intermediate
Write range r to file f :rw f Intermediate
Append range r to file f :rw>>f Intermediate
Insert content of file f below cursor :r f Intermediate
Insert output of command c below cursor :r! c Intermediate
Repeat last substitution (:s) command & Intermediate
Go to next modified buffer :bm Intermediate
Open all buffers in new splits :ba or :sba Intermediate
Open all buffers in new vertical splits :vert ba or :vert sba Intermediate
The position of mark x in an ex range 'x
(example: :'x,'y delete) Intermediate
In an ex range, the next line where pat matches /pat/ Intermediate
In an ex range, the previous line where pat matches ?pat? Intermediate
n lines from the preceding line number in an ex range +n Intermediate
n lines before the preceding line number, in an ex range -n Intermediate
Look up keyword under cursor with man K Intermediate
Forward to start of next method ]m Intermediate
Backward to start of previous method [m Intermediate
Move to global definition of symbol under cursor gD Intermediate
Move to local definition of symbol under cursor gd Intermediate
Open a window for each file in the argument list :all Intermediate
Display the argument list :args Intermediate
List the leaves in the tree of (undoable) changes :undol[ist] Intermediate
Go to previous text state (may cross undo branches) g- Intermediate
Go to next text state (may cross undo branches) g+ Intermediate
Set up automatic wrapping when reaching right margin n :wrapmargin n Intermediate
Turn off automatic wrapping :wrapmargin 0 Intermediate
Turn on line numbers :set number Intermediate
Turn off line numbers :set nonumber Intermediate
List of your movements :ju(mps) Advanced
List of your recent commands :his[tory] Advanced
Lowercase line guu Advanced
Uppercase line gUU Advanced
Display hex, ascii value of character under cursor ga Advanced
Display hex value of utf-8 character under cursor g8 Advanced
Rot13 whole file ggg?G Advanced
Add n to next number on same line as the cursor n<C-A> Advanced
In insert mode, insert value of expression (ie 5*5) into text <C-R>=expr Advanced
Subtract n (default 1) from next number on same line as cursor n<C-X> Advanced
Execute the macro recorded in register x on all lines of the current file :%normal @x Advanced
Execute the macro recorded in register x on a visually selected set of lines :normal @x Advanced
Show lines in file matching word under cursor [I (capital 'I') Advanced
Move cursor n sentences forward n) Advanced
Move cursor n sentences backward n( Advanced
Move cursor n paragraphs forward n} Advanced
Move cursor n paragraphs backward n{ Advanced
Paste below the current line, adjusting indentation to match current line ]p Advanced
Paste above the current line, adjusting indentation to match current line [p Advanced
Go to center of screen on current line gm Advanced
Column n of current line n| Advanced
Insert previously inserted text and return to command mode (Insert mode) <C-@> Advanced
Insert content of register x (Insert mode) <C-R>x Advanced
Insert digraph (Х“ УЉ УБ etc.) <C-K>c1c2 Advanced
Put register after cursor position, leaving cursor after new text gp Advanced
Put register before cursor position, leaving cursor after new text gP Advanced
Format lines of movement m as plain text gqm Advanced
Center lines in range r to width n :rce n Advanced
Left align lines in range r with indent n :rle n Advanced
Right align lines in range r to width n :rri n Advanced
In visual mode, select a word aw Advanced
In visual mode, select a sentence as Advanced
In visual mode, select a paragraph ap Advanced
In visual mode, select a block delimited by ( ) ab Advanced
In visual mode, select a block delimited by { } aB Advanced
Move cursor down n-1 lines to first non-blank character n_ Advanced
Move backward to start of section [[ Advanced
Move forward to start of next section ]] Advanced
Move backward to previous section end [] Advanced
Move forward to next section end ][ Advanced
Move backward to previous unclosed ( [( Advanced
Move forward to next unclosed ) ]) Advanced
Move backward to previous unclosed { [{ Advanced
Move forward to next unclosed } ]} Advanced
List matching tags (and select) :ts Advanced
Split window and show tag under cursor <C-W>] Advanced
Preview tag under cursor <C-W>{ Advanced
Preview tag t :pt t Advanced
Close tag preview window <C-W>z or :pc Advanced
Visual area expressed as an ex range *
(Example: :* delete) Advanced
Create a fold for motion m in manual folding mode zfm Advanced
Create a fold for the visually highlighted text in manual folding mode zf Advanced
Create a fold for n lines in manual folding mode nzF Advanced
Create a fold for the range of lines r in manual folding mode :rfo[ld] Advanced
Delete one folding level at the cursor in manual folding mode zd Advanced
Delete all folds recursively at the cursor in manual folding mode zD Advanced
Eliminate all folds in the window in manual folding mode zE Advanced
Open n levels of folding at the cursor nzo
(default 1 level when no count provided) Advanced
Open all folds under the cursor (or visual selection) recursively zO Advanced
Close n levels of folding under the cursor nzc
(default 1 level when no count given) Advanced
Close all folds under the cursor (or visual selection) recursively zC Advanced
Toggle n levels of folding (close open folds; open closed folds) nza Advanced
Toggle folding recursively (close open folds and open closed folds) zA Advanced
Open just enough folds to make the line in which the cursor is located not folded zv Advanced
Open all folds zR Advanced
Fold none: All folds will be open zn Advanced
Fold normal: All folds will be as they were before (opposite of fold none) zN Advanced
Move to start of current open fold [z Advanced
Move to end of current open fold ]z Advanced
Move down to start of next fold zj Advanced
Move up to end of previous fold zk Advanced
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment