Skip to content

Instantly share code, notes, and snippets.

@subfuzion
Created February 26, 2014 19:06
Show Gist options
  • Save subfuzion/9236227 to your computer and use it in GitHub Desktop.
Save subfuzion/9236227 to your computer and use it in GitHub Desktop.
VI keys

Just a quick and dirty memory aid for common things.

Undo, Redo, and Repeat

Action Keys
Undo u or :u
Undo all changes to line U
Redo undone change Ctrl-R or :red[o]
Repeat last command .

Basic cursor navigation

Action Keys
Top of file gg or 1G
End of file G or 0G
Specific line #G
Home row H
Middle row M
Last row L
Move to beginning of next word w
Move to end of next word e
... ignore punctuation E
Move to beginning of prev word b
... ignore punctuation B
Move to beginning of line 0
Move to 1st non-blank ch in line ^
Move to end of line $
Move to next sentence )
Move to prev sentence (
Move to next paragraph }
Move to prev paragraph {
Page up (back) Ctrl-b
Page down (forward) Ctrl-f
Half page up Ctrl-u
Half page down Ctrl-d
Cursor left, down, up, right h, j, k, l

Basic editing

Action Keys
Open (append) blank line o
Open (insert) blank line O
Insert at cursor i
Insert at beginning of line I
Append at cursor a
Append at end of line A
Append at end of word ea
Delete char at cursor x
Delete char before cursor X
Single char replace at cursor r
Delete char at cursor and edit s
Enter insert mode, overwrite R
Delete line dd
Delete from cursor to line end D

Advanced editing

Action Keys
Insert chars block (comments...) Ctrl-v, jj..., I, , Esc
Delete chars block Ctrl-v, jj..., l, d
Indent >>
Unindent (outdent) <<
Multi-line indent Shift-v, jj..., [n]>
Multi-line unindent Shift-v, jj..., [n]<

Copy and Paste

Action Keys
Yank (copy) word yw
Yank (copy) line yy
Yank (copy) to line end y$
Yank (copy) to line beginning y^
Delete (cut) word dw
Delete (cut) line dd
Delete (cut) to line end d$
Delete (cut) to line beginning d^
Paste after cursor p
Paste before cursor P

Buffers

Action Keys
Cycle through buffers Ctrl-^
Switch to buffer # :b#
Switch to buffer ... :b sp tab
Switch to next :bn
Switch to previous :bp
Delete buffer :bd
Open new buffer :e
Open new buffer in split :sp filename

View

Action Keys
Create a new view and edit :new
Split view horizontally :sp[lit]
Split view vertically :vs[plit] or Ctrl-wv
Move to next view Ctrl-ww
Move to left, down, up, right Ctrl-w h,j,k,l
Close current view (no edits) :q
Close current view, save :wq or ZZ
Close current view, don't save :q!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment