Skip to content

Instantly share code, notes, and snippets.

Start new Change

In VIM a new change usually only starts when you leave insert mode (i.e. if you press u for undo, everything in the last insert is reverted). By pressing ctrl+g and then u, you can start a new change while in insert mode. You could even map the return key to do this automatically when you start a new line: :inoremap u (undo will now only undo single lines).

@BastianHofmann
BastianHofmann / mad_vim_skills_11.md
Created May 29, 2018 06:59
Mad VIM Skills #11

Ack Search Word under Cursor

Use :Ack to search for the word under the cursor accross all files in the current working directory.

Swap Files Location

You can tell VIM to store your swap files in a fixed directory, instead of mixed in with your other files, by setting for example set directory^=~/.vim/tmp/swap//.

@BastianHofmann
BastianHofmann / mad_vim_skills_9.md
Created May 24, 2018 09:38
Mad VIM Skills #9

CtrlP Open in New Split

Use ctrl+v to open the highlighted result in CtrlP in a new split.

NERDTreeFind

To reveal the current buffer in NERDTree use the :NERDTreeFind command. This will also open NERDTree if it's closed. You can map the command to a shortcut if you want to.

Screen Jumping

Use H to the top of the screen, L to the bottom of the screen and M to jump to the middle of the screen.

Search for Word under Cursor

Press * in command mode to search for the word under the cursor in the open buffer.

@BastianHofmann
BastianHofmann / mad_vim_skills_5.md
Last active June 5, 2018 08:20
Mad VIM Skills #5
@BastianHofmann
BastianHofmann / mad_vim_skills_4.md
Last active June 5, 2018 08:20
Mad VIM Skills #4

Write and Quit

You can use :x or ZZ to write and quit instead of :wq.

@BastianHofmann
BastianHofmann / mad_vim_skills_3.md
Last active June 5, 2018 08:20
Mad VIM Skills #3

Undo and Redo

Use u in command mode to undo the last action and ctrl+r to redo the action. You can also use [count]u and [count]ctrl+r to undo and redo multiple times. You can also use U to revert all the changes in the last modfied line.