Digital Garden

Vim Cheatsheet

Cheatsheet for VIM commands

File Management


:q      close
zq      quit all
zz      save and quit

Nerd Tree:

<ctrl>+n            toggle nerd tree
o/O                 open file or directory / open recursively
x/X                 close file or directory / close recursively
c                   open directory in new NDT pane
C                   make directory root
u/U                 move root directory up / move but stay
r/R                 refresh directory / refresh root
p/P                 go to parent / go to root
f                   toogle file filters
:Bookmark [<name>]  add book mark with name
D                   delete bookmark
m                   new, delete, or move files

Split & Tab Management


<ctrl>+h  hop left
<ctrl>+j  hop down
<ctrl>+k  hop up
<ctrl>+l  hop right

:sp     open horizontal split
:vsp    open vertical split

<ctrl>+w o    fullscreen pane


gt      next tab
gT      last tab
tabm #  go to tab #


s       open in vertical split
i       open in horizontal split

Fuzzy File Open

<ctrl>+p    start file search
<ctrl>+v    open in vertical split
<ctrl>+s    open in horizontal 
<ctrl>+t    open in tab
<ctrl>+y    creae a new file


zc  closes fold


Vim Modes:

a/e/i   insert mode
escape  command mode
v       visual mode
f3      toggle numbers

Text Manipulation


y       copy
p       paste
x       cut
space+v paste from clipboard
space+y copy to clipboard


d       delete character
d$      delete to end of line
dGG     delete to end of file
dd      delete line


r       redo
u       undo

Search & Replace:

:%s/*/*   search and replace

Moving About

Character movement:

h       left
j       down
k       up
l       right

Jump about:

#G      jump to line #
^       start of line
$       end of line
b       back a word
w       forward a word


/       search
n       next search match
N       last search match

Fuzzy Search

f5          purge cache
<ctrl>+r    regex mode
<ctrl>+d    filename mode


f5      start script
f2      step over
f3      step into
f4      step out
f6      kill script
f7      detach from debugger
f10     toggle breakpoint
f12     evaluate variable under cursor


\s      spellcheck dialog
]s      next misspelled word
[s      last misspelled word
zg      add word to dictionary
zw      mark word as wrong
zug     undo add word
zuw     undo wrong word

SQL Plug

<space>sp       select mysql preset
<space>sd       set database
<space>rf       run file
<space>rs       run statement
<space>dl       list databases
<space>tl       list tables
<space>td       describe table


<space>tt           show method/variable breakdown for class
<space>fs           fix highlighting
q+[a-z]             start/stop recording macro
<space>gc           toggle comment
<space>gw           format to line length
<space>pd           start doc block
<space>fj           format json
<space>fr           format sql
<space>a+[^|<>l::|] fix alignment
<shift>+k           open documentation in pane

<ctrl>+x <ctrl>+f   open file selector
<ctrl>+n            start autocomplete
<ctrl>+n, <ctrl>+p  cycle through autocomplete options

Linked References