mapclear! abclear noremap :tabprev noremap :tabnext noremap gf gf if exists(':TlistToggle') noremap :TlistToggle endif noremap f $zf% noremap i :call InsertHeader() noremap tt :call RotateKeywords() noremap ss :call ToggleSQLMode() " custom abbrevations for Perl modules I use a lot function! LeaderAbbreviate(lhs, rhs) let code = "inoremap " . a:lhs . " " . a:rhs execute l:code endfunction let ddc_installed = system("perl -e '$ok = eval { require Data::Dumper::Concise }; print($ok ? 1 : 0);'") if ddc_installed call LeaderAbbreviate('uddc', 'use Data::Dumper::Concise;') else call LeaderAbbreviate('uddc', 'use Data::Dumper;') endif call LeaderAbbreviate('uddp', 'use Data::Printer;') call LeaderAbbreviate('utm', 'use Test::More;') let perl_version = system("perl -e 'print $]'") let perl_version = substitute(perl_version, '^5[.]', '', '') let perl_major_version = substitute(matchstr(perl_version, '...'), '^0*', '', '') if perl_major_version >= 10 call LeaderAbbreviate('ufs', 'use feature qw(say);') else call LeaderAbbreviate('ufs', 'use Perl6::Say;') end inoremap inoremap inoremap nnoremap zo zO inoreabbrev deafult default inoreabbrev langauge language " Make Y behave like other capitals noremap Y y$ cnoremap cnoremap cabbrev q1 q! cabbrev ssu sus cabbrev us sus cabbrev Sus sus cnoreabbrev su sus cnoreabbrev Help help cnoreabbrev tanbew tabnew vnoremap = :Tabularize assignment nnoremap ev :vsplit $MYVIMRC nnoremap sv :source $MYVIMRC let s:handy_mappings = [] function! s:DefineHandyMapping(char, command) call add(s:handy_mappings, [ a:char, a:command ]) execute 'nnoremap ' . a:char . ' ' . a:command . '' endfunction function! s:DisplayHandyMappings() for pair in s:handy_mappings echo pair[0] . ' ' . pair[1] endfor endfunction call DefineHandyMapping('n', ':set number!') call DefineHandyMapping('l', ':set list!') call DefineHandyMapping('s', ':set spell!') call DefineHandyMapping('i', ':set ignorecase!') call DefineHandyMapping('p', ':set paste!') nnoremap ? :call DisplayHandyMappings() nnoremap vnoremap . :normal . vnoremap , :normal A, nnoremap :previous nnoremap :next " tmux-friendly window mappings function! FigureOutWindows(vim_direction, tmux_direction) let current_tab = tabpagenr() let num_windows = tabpagewinnr(current_tab, '$') " it would be nice if this determined if a window existed " in the direction we're going rather than just counting if !empty($TMUX) && num_windows == 1 call system('tmux select-pane -' . a:tmux_direction) else execute 'wincmd ' . a:vim_direction endif endfunction nnoremap h :call FigureOutWindows('h', 'L') nnoremap j :call FigureOutWindows('j', 'D') nnoremap k :call FigureOutWindows('k', 'U') nnoremap l :call FigureOutWindows('l', 'R') function! SwapLastTwoChars() let cmdline = getcmdline() let cursor = getcmdpos() if cursor > len(cmdline) let cursor = len(cmdline) endif let cursor = cursor - 1 " 0-index it return cmdline[:cursor - 2] . cmdline[cursor] . cmdline[cursor - 1] . cmdline[cursor + 1:] endfunction cnoremap eSwapLastTwoChars() " work in concert with a CompleteDone mapping autocommands.vim function! ForceCaseSensitiveCompletion() let b:oldignorecase=&l:ignorecase setlocal noignorecase iunmap iunmap iunmap return '' endfunction function! RestoreOldCaseSensitivity() if !has_key(b:, 'oldignorecase') return endif let &l:ignorecase=b:oldignorecase unlet b:oldignorecase inoremap =ForceCaseSensitiveCompletion() inoremap =ForceCaseSensitiveCompletion() inoremap =ForceCaseSensitiveCompletion() endfunction inoremap =ForceCaseSensitiveCompletion() inoremap =ForceCaseSensitiveCompletion() inoremap =ForceCaseSensitiveCompletion() nnoremap ga :UnicodeName