Skip to content

Instantly share code, notes, and snippets.

@fbuys
Last active July 27, 2021 18:45
Show Gist options
  • Save fbuys/840ec9e69a8cb145fe1efda6bd8e56e1 to your computer and use it in GitHub Desktop.
Save fbuys/840ec9e69a8cb145fe1efda6bd8e56e1 to your computer and use it in GitHub Desktop.
Vim Essentials Cheatsheet

Buffers

A buffer is a file opened in memory.

Purpose Command
Go to buffer using ID or Name :buffer <id_or_name>
Go to next buffer :bnext or :bn
Go to previous buffer :bprevious or :bp
Go to first buffer :bfirst or :bf
Go to last buffer :bfirst or :bl
Add file to buffer list :badd <filename>
Delete buffer by ID or Name :bdelete <filename>
Delete buffers by ID :<from_id>,<to_id>bdelete
Delete all buffers :%bdelete
HELP :help buffers or :help :buffers
:help buffers
:help :buffers
Purpose Key
Go to alternate (#) buffer CTRL-^
Go to specific with ID buffer 3 CTRL-^

Windows

A window is a workspace for viewing buffers

Purpose Command
Close window :q
Force close window :q!
HELP :help windows
HELP :help window-move-cursor
HELP :help window-moving
HELP :help window-resize
Purpose Key
Split window horizontally CTRL-w s
Split window vertically CTRL-w v
Open new file in h-split window CTRL-w n
Open alternate (#) in h-split window CTRL-w ^
Open buffer in h-split window <id> CTRL-w
Move cursor to top window CTRL-w k
Move cursor to left window CTRL-w h
Move cursor to right window CTRL-w l
Move cursor to bottom window CTRL-w j
Rotate window layout CTRL-w r
Exchange window with next CTRL-w x
Resize to equal sizes CTRL-w =
Decrease window height CTRL-w -
Increase window height CTRL-w +
Decrease window width CTRL-w <
Increase window width CTRL-w >
:help windows
:help opening-window
:help window-move-cursor
:help window-moving
:help window-resize

Tabs

A tab is a container for a one or multiple of windows

Purpose Command
Open a new tab :tabnew or :tabe
Close the current tab :tabclose or :tabc
Close all except current tab :tabonly or :tabo
Purpose Key
Go to next tab gt
Go to previous tab gT
:help tab-page

Arglist

A arglist is a container holding a subset of buffers

Purpose Command
Display the arglist :args
Add file to the arglist :argadd
Execute on every file in arglist :argdo
To next file in arglist :next
To previous file in arglist :prev
To first file in arglist :first
:help arglist

Mapping new keys

Purpose Command
Map in Normal mode :nmap
Map in Insert mode :imap
Map in Visual mode :xmap
Map in CLI mode :cmap
Non-recursive map in CLI mode :nnoremap
Non-recursive map in CLI mode :inoremap
Non-recursive map in CLI mode :vnoremap
Non-recursive map in CLI mode :cnoremap
:help mapping
:help leader
:help key-notation

Jumps

Purpose Key
Go to previous cursor position <C-o>
Go to next cursor position <C-i>
Go to previous change g;
Go to next change g,
Go to start of method [m
Go to end of method ]m
:help jump-motions
:help jumplist
:help changelist

Repeating Keystrokes

Purpose Key
Repeat last change <C-o>
Repeat last command <C-o>
:help single-repeat
:help complex-repeatF

Command Line Window

Purpose Key
Open command history q: OR :hostory :
Open search history :q/ AND q? OR :history / AND :history ?
:help cmdline-window
:help 'history'

Undo Tree

:help undo-redo
:help undo-persistence
:help undo-tree

'g' Keystrokes

Purpose Key
Edit file under cursor gf
Open file under cursor using default application gx
Go to last change [INSERT] gi
Go to last selection [VISUAL] gv
Select match of last search [VISUAL] gn
Insert text at first non-blank gI
Print ascii, hex, oct in cli ga
Motion to lowercase gu
Motion to uppercase gU

Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment