h, j, k, l: move cursori: enter insert modeESC: leave current modeESC + :wq: write and quitESC + :q!: quit (force)# move cursor
h j k l
# move relative
8j
# will move 8 line down
G # go to last line
gg # go to first line
5G # go to line 5
w # move to beginning of next word
b # move to previous beginning of word
e # move to end of word
W # move to beginning of next word after a whitespace
B # move to beginning of previous word before a whitespace
E # move to end of word before a whitespace
0 # move to beginning of line
$ # move to end of line
_ # move to first non-blank character of the line
g_ # move to last non-blank character of the line
f<char> # to next <char> cursor is on <char> (same line)
F<char> # to previous <char> cursor is on <char> (same line)
t<char> # to next <char> cursor is before (same line)
F<char> # to previous <char> cursor is after (same line)
# you can combine
df" # delete to " and "
dt" #delete to "
d% # delete to the pair bracket/parenthesis
. # repead the delete
; # repeat the find
H: move cursor to top of screenM: move cursor to middle of screenL: move cursor to bottom of screenzz: move view pane to middle this linezt: move view pane to top this linezb: move view pane to bottom this lineCTRL+y: move cursor view pane upCTRL+e: move cursor view pane downi: (insert) enter insert mode (before cursor)a: (append) enter insert mode (after cursor)I: insert at the start of the line (before the first word)A: append at the end of the line (after the last word)u: undoCTRL + a: increment number on the lineCTRL + x: decrement number on the lineCTRL + r: undo undoCTRL + R: insert registerCTRL + R + =: evaluate and insert (easing calculation)C - delete to the end of lineci[ - or ci" ci( # change between the charciw - inner worddaw - word and spaceJ - collapse next line with spacegJ - collapse next line without spacegU - majgUiw - maj current wordg~ - inverse on the deplacementg~$ - inverse until end of linedap - delete paragraph and linedip - delete paragraphgq - reformatgqip - reformat inner paragraph/<word>: search then enter then n and N?<word>: search before then enter//: redo the search*: search the current word%: jump to bracket pairma: place a marker'a: go to markerx: delete characterro: replace current letter by odd: delete and copy lineyy: copy (yank) a linep: paste after cursorP: paste before cursorv: select inside line (complete with h or l)V: select lines (complete with j or k)CTRL + v: start visual blocgh: character-wise select modegH: line-wise select modegCtrl-h: block-wise select modey: copy selectiond: delete selection# switch between splits
CTRL-w h
CTRL-w j
CTRL-w k
CTRL-w l
You should have a clipboard util like xclip installed
"*y: copy on mouse clipboard"*p: paste on mouse clipboard"+y: copy on system clipboard"+p: paste on system clipboard:registers or :reg: view the registers"""0-9: previously copied things"-"a "b.."z": ". "%"#"="* and "+"_"/q<register><commands>q: record a macro@<register>: then to play it@@: replay the replayed macro:s/toto/tata: replace current line:%s/toto/tata/g - replace in file:%s/toto/tata/gc - ask yes no before replacing:g/WORD/d - delete all lines with WORD:g@WORD@d - delete all lines with WORD (change of delimiter):v/WORD/d - delete all lines without WORD (or :g!/):g/word/g/name/d - execute on line with word and name:g/word/normal <keys> - execute on line with word:g/word/normal @a - execute a macro on line with word1G!Gsort - sort a file:sort - sort file:sort u - sort unique:set tw=20 - set width:set nowrap - to disable wrap lines:set wrap - to enable wrap lines:new filename.ext - open/create file in new tab:vert new filename.ext - open/create file in new vertical split:%y+ - # copy full file:bd - close the buffer:close - close the window:w ++p - write file and create directories:r file.txt - read and insert a file:!echo 1 - launch shell commands:r !echo 1 - launch shell commands and capture output in the file (will insert 1):w !cmd - write to external:windo !git add % - do the command on windows:mksession: save the session (windows disposition):source session.vim: load the session (or vim -S sessions.vim):set sessionoptions?: check what you save on the session:wviminfo: write a viminfo file:set nofixendofline and :set noendofline: get ride of the last newlineSelect the json with shift + V then run
:!jq: to prettify:!jq -c: to uglifyCTRL+w: windows shortcutCTRL+w + n: new window (or :new)CTRL+w + CTRL+v: split window (or :vs)CTRL+w + l: move to right windowCTRL+w + j: move to down windowCTRL+w + v: open a new vertical split (:vsplit)CTRL+w + s: open a new horizontal split (:split)CTRL+w + c: close windowCTRL+w + o: current window the only screen:tabnew file.txt: Open file.txt in a new tab:tabclose: Close the current tab:tabnext: Go to next tab:tabprevious: Go to previous tab:tablast: Go to last tab:tabfirst: Go to first tabgt: go to next tabgT: go to previous tabgcc: Comment line{Visual}gc: Comment or uncomment the selected line(s).# generate tags
ctags -R --exclude=node_modules .
CTRL+]: jump to the tag:tag NAME: jump to the tagzf: with a selection, create a foldzfj: fold 2 lineszfip: fold paragraphzfG: fold to end of filezfa{: fold between {}zo: open the foldzc: close the foldza: toggle a foldzR: open all foldszM: close all folds:set foldmethod?: see the current fold method
foldmethod=manual: default onefoldmethod=indent: fold on indent, combine with shiftwidthfoldmethod=expr: fold on exp, combine with foldexprfoldmethod=syntax: fold on syntaxfoldmethod=diff: fold on difffoldmethod=marker: fold on marker, combine with foldmarker:mkview: save the folds:loadview: restore the folds