dotar/vim/settings/yadr-keymap-linux.vim

76 lines
2.2 KiB
VimL
Raw Normal View History

2014-07-17 06:51:45 +08:00
" ========================================
" Linux specific General vim sanity improvements
" ========================================
"
" ========================================
" RSI Prevention - keyboard remaps
" ========================================
" Certain things we do every day as programmers stress
" out our hands. For example, typing underscores and
" dashes are very common, and in position that require
" a lot of hand movement. Vim to the rescue
"
" Now using the middle finger of either hand you can type
2014-09-30 04:09:30 +08:00
" underscores with Alt-k or Alt-d, and add Shift
2014-07-17 06:51:45 +08:00
" to type dashes
2014-09-30 04:09:30 +08:00
imap <silent> <A-k> _
imap <silent> <A-d> _
imap <silent> <A-K> -
imap <silent> <A-D> -
2014-07-17 06:51:45 +08:00
2014-09-30 04:09:30 +08:00
" Change inside various enclosures with Alt-" and Alt-'
2014-07-17 06:51:45 +08:00
" The f makes it find the enclosure so you don't have
" to be standing inside it
2014-07-17 21:37:45 +08:00
nnoremap <A-'> f'ci'
nnoremap <A-"> f"ci"
nnoremap <A-(> f(ci(
nnoremap <A-)> f)ci)
nnoremap <A-[> f[ci[
nnoremap <A-]> f]ci]
2014-07-17 06:51:45 +08:00
" ==== NERD tree
2014-09-30 04:09:30 +08:00
" Alt-Shift-N for nerd tree
nmap <A-N> :NERDTreeToggle<CR>
2014-07-17 06:51:45 +08:00
2014-09-30 04:09:30 +08:00
" move up/down quickly by using Alt-j, Alt-k
2014-07-17 06:51:45 +08:00
" which will move us around by functions
2014-09-30 04:09:30 +08:00
nnoremap <silent> <A-j> }
nnoremap <silent> <A-k> {
autocmd FileType ruby map <buffer> <A-j> ]m
autocmd FileType ruby map <buffer> <A-k> [m
autocmd FileType rspec map <buffer> <A-j> }
autocmd FileType rspec map <buffer> <A-k> {
autocmd FileType javascript map <buffer> <A-k> }
autocmd FileType javascript map <buffer> <A-j> {
2014-07-17 06:51:45 +08:00
" Command-/ to toggle comments
2014-09-30 04:09:30 +08:00
map <A-/> :TComment<CR>
imap <A-/> <Esc>:TComment<CR>i
2014-07-17 06:51:45 +08:00
" Use Alt- numbers to pick the tab you want
map <silent> <A-1> :tabn 1<cr>
map <silent> <A-2> :tabn 2<cr>
map <silent> <A-3> :tabn 3<cr>
map <silent> <A-4> :tabn 4<cr>
map <silent> <A-5> :tabn 5<cr>
map <silent> <A-6> :tabn 6<cr>
map <silent> <A-7> :tabn 7<cr>
map <silent> <A-8> :tabn 8<cr>
map <silent> <A-9> :tabn 9<cr>
" Resize windows with arrow keys
nnoremap <C-Up> <C-w>+
nnoremap <C-Down> <C-w>-
nnoremap <C-Left> <C-w><
nnoremap <C-Right> <C-w>>
" ============================
" Tabularize - alignment
" ============================
2014-09-30 04:09:30 +08:00
" Hit Alt-Shift-A then type a character you want to align by
nmap <A-A> :Tabularize /
vmap <A-A> :Tabularize /
2014-07-17 06:51:45 +08:00
2014-09-30 04:09:30 +08:00
" Source current file Alt-% (good for vim development)
map <A-%> :so %<CR>