Search/Replace

:%s/old/new/g - replace all old with new throughout file (gn is better though)

:%s/old/new/gc - replace all old with new throughout file with confirmations

Working with multiple files

:e filename - Edit a file

:tabe - make a new tab

gt - go to the next tab

gT - go to the previous tab

Advanced

:vsp - vertically split windows

ctrl+ws - Split windows horizontally

ctrl+wv - Split windows vertically

ctrl+ww - switch between windows

ctrl+wq - Quit a window

Marks

Marks allow you to jump to designated points in your code.

m{a-z} - Set mark {a-z} at cursor position

A capital mark {A-Z} sets a global mark and will work between files

‘{a-z} - move the cursor to the start of the line where the mark was set

‘’ - go back to the previous jump location

General

u - undo

Ctrl+r - redo

. - repeat last command

Making Vim actually useful

Vim is quite unpleasant out of the box. For example, typeing :w for every file save is awkward and copying and pasting to the system clipboard does not work. But a few changes will get you much closer to the editor of your dreams.

You should now be able to press [space]w in normal mode to save a file.

[space]p should paste from the system clipboard (outside of vim).

If you can’t paste, it’s probably because vim was not built with the system clipboard option. To check, run vim --version and see if +clipboard exists. If it says -clipboard, you will not be able to copy from outside of vim.

For mac users, homebrew install vim with the clipboard option. Install homebrew and then run brew install vim.

then move the old vim binary: $ mv /usr/bin/vim /usr/bin/vimold

restart your terminal and you should see vim --version now with +clipboard

Plugins

The easiest way to make vim more powerful is to use Vintageous in sublime (version 3). This gives you Vim mode inside sublime. I suggest this (or a similar setup with the Atom editor) if you aren't a vim master. Check out Advanced Vim if you are.

Vintageous is great, but I suggest you change a few settings to make it better.

Clone this repository to ~/.config/sublime-text-3/Packages/Vintageous, or similar. Then check out the "custom" branch.

Alternatively, you can get a more updated Vintageous version by cloning the official repo and then copying over this patch.