Skip to content

Instantly share code, notes, and snippets.

@BastianHofmann
BastianHofmann / mad_vim_skills_14.md
Last active June 18, 2018 09:40
Mad VIM Skills #14

Use b# to switch to the previous buffer (i.e. the file which was previously edited)

Edit multiple files in a row

You can open multiple files and edit them in a row (e.g. vim *.json or vim a.txt b.txt). Use :wn to write the current file and open the next.

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