Skip to content

Instantly share code, notes, and snippets.

@sarnobat
Last active May 2, 2025 20:25
Show Gist options
  • Save sarnobat/9ed216ea3bd7be0cce643e449805ddfe to your computer and use it in GitHub Desktop.
Save sarnobat/9ed216ea3bd7be0cce643e449805ddfe to your computer and use it in GitHub Desktop.
vim_commands

created using radial network d3 diagram: https://www.reddit.com/r/vim/comments/1kaxowx/request_for_feedback_radial_vim_index_of_commands/#lightbox

See also: https://docs.google.com/spreadsheets/d/1sx7KwWUFb3gzMyK-zMKI_OraH6yp7ftG-ZNgAjmyZ4Q/edit?pli=1&gid=1431583610#gid=1431583610

normal commands

j
k
w                  cursor N words forward
b                  

0                  
^                  cursor to the first CHAR of the line
$                  

t                  cursor till before Nth occurrence of {char} to the right
t/                 cursor till before Nth occurrence of / to the right
t/;                cursor till before Nth occurrence of / to the right then repeat latest f, t, F or T 1 times
t/;;               cursor till before Nth occurrence of / to the right then repeat latest f, t, F or T 2 times
t/;;;              cursor till before Nth occurrence of / to the right then repeat latest f, t, F or T 3 times
t/.                cursor till before Nth occurrence of / to the right then repeat latest f, t, F or T in opposite direction 1 times
t/..               cursor till before Nth occurrence of / to the right then repeat latest f, t, F or T in opposite direction 2 times
t/...              cursor till before Nth occurrence of / to the right then repeat latest f, t, F or T in opposite direction 3 times
f                  

}                  cursor N paragraphs backward
{                  cursor N parag
%                  find the next (curly/square) bracket on this line and go to its match, or go to matching comment bracket, or go to matching preprocessor directive.

d                  delete the characters under the cursor until the end of the line and N-1 more
dd                 delete N lines [into buffer x]
x                  delete N characters under and after the cursor [into buffer x]
u                  undo changes
~                  'tildeop' off: switch case of N characters under cursor and move the cursor N characters to the right

yy                 yank N lines [into buffer x]              

z commands

zo                 open fold
za                 open a closed fold, close an open fold
zM                 set 'foldlevel' to zero
zR                 set 'foldlevel' to the deepest fold

zz                 redraw, cursor line at center of window
z.

g commands

Extended commands

gM                 go to character at middle of the screenline
gM                 cursor to line N, default first line
gd                 go to definition of word under the cursor in current function

Z commands

ZZ                 store current file if modified, and exit
ZQ                 exit current file always

backtick (`) commands

``                 cursor to the position before latest jump
`.                 ?????
`A
`V

Ctrl commands

Ctrl+]             jump to ident under cursor
Ctrl+] Ctrl+t      jump to ident under cursor, then jump to N older Tag in tag list
Ctrl+] Ctrl+o      jump to ident under cursor, go to N older entry in jump list

Ctrl w commands

Ctrl+w Ctrl+w      go to N previous window (wrap aroun
Ctrl+w Shift+I     split window and jump to declaration of identifier under the curs

colon (:) commands

:w                 write to a file
:wq                write to a file and quit window or Vim
:x                 write if buffer changed and quit window or Vim

:%
:,
:,$
:1,$p
:1,$n
:1,5p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment