vim tips and tricks

mapping

Use mappings to save typing for things you frequently type. The first one below, when typing in insert mode, changes every occurrence of ;so to System.out.println(); and leaves you in insert mode between the parentheses!

 imap ;so System.out.println();<left><left>
 imap ;ne <esc>/;<cr>a
 vmap <buffer> ;bo "zdi<B><c-r>z</B><esc>

The second one above, while in insert mode, moves you to the end of the next line when you type ;ne. The last one puts bold html tags around something you have visually selected.

These usually go in your .vimrc file. You can even have certain mappings loaded based on the type of file you are editing.

Quiz: what do these do? :)

nnoremap <F6> <C-W>w
nnoremap <S-F6> <C-W>W

map <C-L> :noh<CR>:redraw!<CR>