Vim Commands
Some useful commands can be found here.
Command | Description |
---|---|
:g/{pattern}/{cmd} | apply cmd on each search match; default command is print |
:g/{pattern} | search for pattern in current file |
!! | filter current line |
!{motion} | normal mode mapping to feed into a filter command |
au TextChanged * update | autosave file when text changed |
<C-k>-N | insert en-dash using vim digraphs |
:[range]ce[nter] [width] | center the current line to the given width (or width of terminal) |
g?g? | encode whole line with rot13 |
g& | run last substiution command on whole file |
gq | split up long lines to multiple lines |
<C-x><C-n> | autocompletion for current buffer |
<C-x><C-i> | autocompletion for included file keywords |
<C-x><C-]> | autocompletion for tags |
<C-x><C-k> | autocompletion for dictionary |
<C-x><C-l> | autocompletion for whole lines |
<C-x><C-f> | autocompletion for filenames |
<C-x><C-o> | omni-autocompletion; filetype-plugin required |
<C-x><C-s> or <C-x>s | search backwards and correct misspelling in line |
C-e | Cancel completion list |
C-y | Accept completion list |
:e # | edit alternate file |
:function fzf#run | show function definition |
:command FZF | show command definition |
:'<,'>norm . | repeat last operation on each selected line |
ZQ | quit without saving |
:x | write and quit file |
:set spell! | check grammar |
:set spellang=en_us | set spell language (supports regional language) |
:setlocal spellfile+=~/myjargon.utf-8.add | add another good word list |
z= | show grammar corrections 1z= will use first suggestions |
zg | add word to good word list, 2zg will add word to the second good word list |
zw | add word to misspelled word list, 2zw will add word to the second misspelled word list |
:mksession file.vm | Save vim layout to file.vim. Open with vim -S file.vim |
/HAY\zsGOAL/zeHAY | Only select thing between \zs\ze in a regular expression |
C-a / C-x | increment / decrement first number found on current lin |
{ } | go to next paragraph |
( oder ) | go to next sentence |
*/# | search forward/backword for word under cursor (also works in |
g\;/g\, | cycle through :changes |
autocmd CursorHold * update | autosave file when inactive |
:windo difft | vim diff all opened windows |
:b[substring] | search file name in buffer containing substring and edit it |
Ctrl-[n/]p | automcomplete |
gi | continue at last insert position |
Ctrl-t | pop tag stack |
gt | switch to other tab |
Ctrl-[Y/E] | move screen up / down |
[count][e/E] | go to end of word/WORD right |
gf | go to tag cursor is on |
= | make indent the same (gg=G indents entire file |
:set suffixesadd+=.txt | allows gf (go to file) on filenames without suffix |
[count]+ / [count]- | down/up to first non-blank char of line |
g_ | go to last non blank char |
q: | open command line window (or go to ex-mode with : then press C |
m{a-zA-Z} | set bookmarks |
`{mark} | visit bookmark |
Ctrl-] | jump to definition of tag |
gUi' | go Uppercase inside ‘ |
Ctrl-^ | Toggle to previous file |
C-v / C-k in insert mode | paste decimal, hexadecimal and digraphs (:h digraph-table) |
\. | jump to last change |
gd | go to local declaration |
:find | find file in ‘path’ |
[H/L/M] | move cursor to High/Middle/Low of screen |
Ctrl-[I/O] | go to next/previous jump |
Ctrl-[F/B] | Page forward / backwards |
@: | repeat last Ex command |
& | find next matching ),], or } / Repeat last :substitute comman |
Ctrl-r | press in insert mode and then presser name of register to |
OSC52 | clipboard copy |
10% | go 10% down in file |
[zt/zz/zb] | scroll window that cursor is in top/middle/bottom |
:set path+=** | add files recursively to path |
[count]]m | go to beginning of next method |
Ctrl-[D/U] | Scroll Half a Page Down / Up |
C-o in insert mode | switch to normal mode for 1 command and then g |
^ | go to first non blank char |
gj/gk | move down/up on wrapped line |