vim in practice (1)
Vim Practice
<leader>
Vim have a extra key to activate mappings, and call this “prefix” key the “leader”.
*Mapping keys is one of the places where Vim comments does’t work.
1
2
3 let mapleader=','
nnoremap <leader>ev :vsplit $MYVIMRC<cr>
nnoremap <leader>sv :source $MYVIMRC<cr>
Abbrevation
Vim has a feature called “abbreviations” that feel similar to mappings but are meant for use in insert, replace, and command modes.
1
2
3 iabbrev what what
when you type *what<space>*
were substituted with *what<space>*
Disable old keys
This effectively disables the escape key in insert mode by telling Vim to perform
(no operation) instead.
1 | inoremap <esc> <nop> "no operation |
Autocommands
Autocommands are the way to tell Vim to run commands whenever certain events happen.
1 | :autocmd BufNewFile * :write |
System clipboard
1 | BundleInstall fakeclip |