82 lines
2.4 KiB
VimL
82 lines
2.4 KiB
VimL
" ========================================
|
|
" Mac 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
|
|
" underscores with apple-k or apple-d, and add Shift
|
|
" to type dashes
|
|
imap <silent> <D-k> _
|
|
imap <silent> <D-d> _
|
|
imap <silent> <D-K> -
|
|
imap <silent> <D-D> -
|
|
|
|
" Change inside various enclosures with Cmd-" and Cmd-'
|
|
" The f makes it find the enclosure so you don't have
|
|
" to be standing inside it
|
|
nnoremap <D-'> f'ci'
|
|
nnoremap <D-"> f"ci"
|
|
nnoremap <D-(> f(ci(
|
|
nnoremap <D-)> f)ci)
|
|
nnoremap <D-[> f[ci[
|
|
nnoremap <D-]> f]ci]
|
|
|
|
" ==== NERD tree
|
|
" Cmd-Shift-N for nerd tree
|
|
nmap <D-N> :NERDTreeToggle<CR>
|
|
|
|
" move up/down quickly by using Cmd-j, Cmd-k
|
|
" which will move us around by functions
|
|
nnoremap <silent> <D-j> }
|
|
nnoremap <silent> <D-k> {
|
|
autocmd FileType ruby map <buffer> <D-j> ]m
|
|
autocmd FileType ruby map <buffer> <D-k> [m
|
|
autocmd FileType rspec map <buffer> <D-j> }
|
|
autocmd FileType rspec map <buffer> <D-k> {
|
|
autocmd FileType javascript map <buffer> <D-k> }
|
|
autocmd FileType javascript map <buffer> <D-j> {
|
|
|
|
" Command-/ to toggle comments
|
|
map <D-/> :TComment<CR>
|
|
imap <D-/> <Esc>:TComment<CR>i
|
|
|
|
" Use numbers to pick the tab you want (like iTerm)
|
|
map <silent> <D-1> :tabn 1<cr>
|
|
map <silent> <D-2> :tabn 2<cr>
|
|
map <silent> <D-3> :tabn 3<cr>
|
|
map <silent> <D-4> :tabn 4<cr>
|
|
map <silent> <D-5> :tabn 5<cr>
|
|
map <silent> <D-6> :tabn 6<cr>
|
|
map <silent> <D-7> :tabn 7<cr>
|
|
map <silent> <D-8> :tabn 8<cr>
|
|
map <silent> <D-9> :tabn 9<cr>
|
|
|
|
" Create window splits easier. The default
|
|
" way is Ctrl-w,v and Ctrl-w,s. I remap
|
|
" this to vv and ss
|
|
nnoremap <silent> vv <C-w>v
|
|
nnoremap <silent> ss <C-w>s
|
|
|
|
" Resize windows with arrow keys
|
|
nnoremap <D-Up> <C-w>+
|
|
nnoremap <D-Down> <C-w>-
|
|
nnoremap <D-Left> <C-w><
|
|
nnoremap <D-Right> <C-w>>
|
|
|
|
" ============================
|
|
" Tabularize - alignment
|
|
" ============================
|
|
" Hit Cmd-Shift-A then type a character you want to align by
|
|
nmap <D-A> :Tabularize /
|
|
vmap <D-A> :Tabularize /
|
|
|
|
" Source current file Cmd-% (good for vim development)
|
|
map <D-%> :so %<CR>
|