Skip to content

Instantly share code, notes, and snippets.

@remarkablemark
Last active November 7, 2018 17:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save remarkablemark/255f802db2a8051744a97395f716402f to your computer and use it in GitHub Desktop.
Save remarkablemark/255f802db2a8051744a97395f716402f to your computer and use it in GitHub Desktop.
A collection of useful VIM tips and tricks.

Vim Tips

Type Action Command
Editor Reload window :e
:edit
Horizontal split Ctrl w, s
:sp
:split
Vertical split Ctrl w, v
:vs
:vsplit
Switch between windows Ctrl w, (xor Ctrl w, h, j, k, l)
Open new tab :tabe
Go to next tab gt
Go to previous tab gT
Tab move left :-tabm
Tab move right :+tabm
Open buffer in new tab :tabe %
See relative path Ctrl g
See absolute path 1, Ctrl g
Reopen closed buffer :vs#
Go back to previous buffer :e#
Ctrl-^
Movement Jump to top gg
Jump to bottom G
Go back to location of last edit g;
Go forward in edit history g,
Edit Re-indent Visual select, =
Re-indent document gg=G
Replace first in current line :s/original/new
Replace all in current line :s/original/new/g
Search and replace :%s/foo/bar/g
Misc Copy to clipboard :w !pbcopy
Paste from clipboard :r !pbpaste
Suspend Vim Ctrl z
Resume from suspension (commandline) fg
Show trailing whitespace :set list
/\s\+$
@tdlm
Copy link

tdlm commented Mar 17, 2017

To list registers: :reg
To insert from a register: %[reg]p (e.g. %1p)

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