Skip to content

Instantly share code, notes, and snippets.

@Davidslv
Forked from nas/Vim cheat sheet
Created July 22, 2013 14:34
Show Gist options
  • Save Davidslv/6054289 to your computer and use it in GitHub Desktop.
Save Davidslv/6054289 to your computer and use it in GitHub Desktop.
Skipping some of the very basic commands, to use this cheat sheet you need atleast some vim knowledge.
; # repeat last search done using f
, # undo last search done using f
u # undo last change
ctrl+r # redo last change
:%s/t/r/g # replace all 't' by 'r'
~ # change case
gu # to lower case
gU # to upper case
> # shift right
< # shift left
= # auto indent
yt, # yank until ,
yf, # yank including ,
b # beginning of previous word
w # beginning of next word
e # end of next word
o # toggle the free end in visual mode
db # delete from cursor to the beginning of word
dw # delete from cursor to the end of word
daw # delete word irrespective of cursor position
cw # delete from current cursor pos. to the end of word -> insert mode
bcw # move to word beginning + above
dap # delete entire paragraph
viw # visually select a word
vip # visually select a paragraph
viw # visually select a word
cis # change current sentence
c # change
C # c$
s # cl
S # ^C
I # ^i
a # li
A # $a
o # A<enter>
O # ko
>G # increase the indentation from the current line until the end of the file e.g. >G j.

In insert mode:
ctrl+h # backspace
ctrl+w # delete back one word
ctrl+u # delete back start of line
ctrl+r 0 # paste yanked text
ctrl+= # evaluate the expression and insert the result, i.e, 1876*7676
:3t. # cp line 3 below current line
:3m. # mv line 3 below current line
:t3 # cp current line below line 3
:m3 # mv current line below line 3
:t$ # cp current line to end of file
:m$ # mv current line to end of file
:t0 # cp current line to beginning of file
:t. # yyp
v # character visual mode
V # line wise visual mode
ctrl+v # block wise visual mode
ctrl+g # switch between visual & select mode
gv # reselect last visual selection
r: # replace with ':' for the selection in visual mode, except select mode
Tips:
>G j. j. j. j. # one level indent from current line to the EOF, then next line repeat indentation 4 times
gg=G # go to the top of file and auto indent to then EOF
* cw new_word ESC n . . . . . # select all instances of the word, change it, find next and change if required
v b b o w # select visually, go back, change cursor position, go forward
ctrl+v 2je c (type anything) ESC # block visually select and change word on all selected lines
ctrl+v 2j$ A (type anything) ESC # block visually select and add something at the end of all selected lines
zf#j # creates a fold from the cursor down # lines.
zf/string # creates a fold from the cursor to string .
zj # moves the cursor to the next fold.
zk # moves the cursor to the previous fold.
zo # opens a fold at the cursor.
zO # opens all folds at the cursor.
zm # increases the foldlevel by one.
zM # closes all open folds.
zr # decreases the foldlevel by one.
zR # decreases the foldlevel to zero -- all folds will be open.
zd # deletes the fold at the cursor.
zE # deletes all folds.
[z # move to start of open fold.
]z # move to end of open fold.
vim -p file1 file2 ... file_n # open multiple files in tabs in one go
vim -o file1 file2 ... file_n # open multiple files in split windows -o for horizontal and -O vertical splits
# http://vimdoc.sourceforge.net/htmldoc/windows.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment