" File: $HOME/etc/mappings.vim " Author: Magnus Woldrich " Updated: 2011-07-02 17:48:48 let mapleader = ',' nnoremap å :%s/\v\d+/\=submatch(0) + 1/g :normal gg "nmap O :%w >> ~/vim_output "nmap o :exec ':.w >> ' . eval(string( xclipboard_pipe_path )) if &filetype == 'perl' nnoremap :!perl -MVi::QuickFix='/mnt/Docs/Backup/vim_quickfix_err/%.err' -c %:cf nnoremap _t :%!perltidy -q vnoremap _t :!perltidy -q nnoremap _p :%!perlcritic -q vnoremap _p :!perlcritic -q endif " Switch language nmap sp :set syn=perl :syntax sync fromstart nmap ss :set syn=sh :syntax sync fromstart nmap sv :set syn=vim :syntax sync fromstart nmap sz :set syn=zsh :syntax sync fromstart nmap sc :set syn=config :syntax sync fromstart nmap sf :set syn=conf :syntax sync fromstart " Make writing and quitting faster cmap W w cmap qq qa! nmap w :w! " I prefer to jump to the exact same spot as where the cursor was when I created " the mark nnoremap ' ` nnoremap ` ' " jump to the position before the latest jump, or where the " last "m'" or "m`" command was given. Not set when the " |:keepjumps| command modifier was used. nnoremap `` '' nnoremap '' `` " Easier window management map map map j_ map map map = - map + + map \| :vsplit map - :split " For following links in the Vim help nmap " quick access to the history buffer nmap q q: " silly experiment :-) map ö map Ö " Y should do what it's expected to do (d$, D, c$, C) nmap Y y$ nmap d "_d vmap d "_d " align text nmap cl :left nmap cr :right nmap cc :center " Titlecase And Center nnoremap t :call TitleCaseCenter() " XXX this is so simple and so useful vnoremap S :sort " Titlecase The Current Line, thank you nnoremap U :s/\v[a-zåäö]+/\u&/g " allow the use of TAB for jumping between matching pairs " note https://github.com/trapd00r/configs/commit/d7dc036e#L0R74 nnoremap % " make those behave like ci' , ci" nnoremap ci( f(ci( nnoremap ci{ f{ci{ nnoremap ci[ f[ci[ vnoremap ci( f(ci( vnoremap ci{ f{ci{ vnoremap ci[ f[ci[ " pod stuff nnoremap dad /\v^\=head/ W d$xa nnoremap d= f=d$a= nnoremap d> f>d$a> inoremap £1 ()i inoremap £2 []i inoremap £3 {o}O inoremap £4 {}i inoremap £q ''i inoremap £Q ""i inoremap jj inoremap jk nnoremap [7~ :source % nnoremap [2~ :source % " jumping to sub definition nnoremap ]] :call search('^\s*sub .* {$', 'sW') nnoremap [[ :call search('^\s*sub .* {$', 'bsW') nnoremap ][ :call search('^}$', 'sW') nnoremap [] :call search('^}$', 'bsW') " buffer shortcuts nnoremap :bnext nnoremap :bprev nnoremap b :buffers:buffer nnoremap l :ls nnoremap g :e# nnoremap 1 :set ft=perl nnoremap 2 :set ft=c nnoremap 3 :set ft=lua nnoremap 4 :set ft=bash nnoremap 5 :set ft=config nnoremap 6 :set ft=vim nnoremap 7 :7b nnoremap 8 :8b nnoremap 9 :9b nnoremap 0 :10b "nnoremap a :bdelete! nnoremap f :set paste nnoremap s :call RemoveTrailingCrap() nnoremap v V`] " spell map [29~ z= nnoremap za zg nnoremap :call ToggleSpell() nnoremap p :set paste nnoremap :nohl nnoremap ,, :nohl nnoremap " sane regex nnoremap / /\v vnoremap / /\v cnoremap '<,'>s/ '<,'>s/\v cnoremap '<,'>s# '<,'>s#\v cnoremap '<,'>s@ '<,'>s@\v cnoremap %s/ %s/\v cnoremap %s# %s#\v cnoremap %s@ %s@\v cnoremap s/ s/\v cnoremap s# s#\v cnoremap s@ s@\v " directory shortcuts cnoremap $h e ~/ cnoremap $d e ~/devel cnoremap $. e . " emacs keymap in the commandline cnoremap cnoremap cnoremap cnoremap cnoremap cnoremap cnoremap cnoremap cnoremap map [3~ xx " cd to the directory of the open buffer, if possible map cd :cd %:p:h map [1;2A map! [1;2A map [1;2B map! [1;2B map [1;2C map! [1;2C map [1;2D map! [1;2D map [1;2F map! [1;2F map [1;2H map! [1;2H map [2;2~ map! [2;2~ map [3;2~ map! [3;2~ map [5;2~ map! [5;2~ map [6;2~ map! [6;2~ " Fix up M-motion keys map [1;3A map! [1;3A map [1;3B map! [1;3B map [1;3C map! [1;3C map [1;3D map! [1;3D map [1;3F map! [1;3F map [1;3H map! [1;3H map [2;3~ map! [2;3~ map [3;3~ map! [3;3~ map [5;3~ map! [5;3~ map [6;3~ map! [6;3~ " Fix up S-M-motion keys map [1;4A map! [1;4A map [1;4B map! [1;4B map [1;4C map! [1;4C map [1;4D map! [1;4D map [1;4F map! [1;4F map [1;4H map! [1;4H map [2;4~ map! [2;4~ map [3;4~ map! [3;4~ map [5;4~ map! [5;4~ map [6;4~ map! [6;4~ " Fix up C-motion keys map [1;5A map! [1;5A map [1;5B map! [1;5B map [1;5C map! [1;5C map [1;5D map! [1;5D map [1;5F map! [1;5F map [1;5H map! [1;5H map [2;5~ map! [2;5~ map [3;5~ map! [3;5~ map [5;5~ map! [5;5~ map [6;5~ map! [6;5~ " Fix up S-C-motion keys map [1;6A map! [1;6A map [1;6B map! [1;6B map [1;6C map! [1;6C map [1;6D map! [1;6D map [1;6F map! [1;6F map [1;6H map! [1;6H map [2;6~ map! [2;6~ map [3;6~ map! [3;6~ map [5;6~ map! [5;6~ map [6;6~ map! [6;6~ " Fix up M-C-motion keys map [1;7A map! [1;7A map [1;7B map! [1;7B map [1;7C map! [1;7C map [1;7D map! [1;7D map [1;7F map! [1;7F map [1;7H map! [1;7H map [2;7~ map! [2;7~ map [3;7~ map! [3;7~ map [5;7~ map! [5;7~ map [6;7~ map! [6;7~ " Fix up S-M-C-motion keys map [1;8A map! [1;8A map [1;8B map! [1;8B map [1;8C map! [1;8C map [1;8D map! [1;8D map [1;8F map! [1;8F map [1;8H map! [1;8H map [2;8~ map! [2;8~ map [3;8~ map! [3;8~ map [5;8~ map! [5;8~ map [6;8~ map! [6;8~ " M-[character] map 0 map! 0 map 1 map! 1 map 2 map! 2 map 3 map! 3 map 4 map! 4 map 5 map! 5 map 6 map! 6 map 7 map! 7 map 8 map! 8 map 9 map! 9 map - map! - map = map! = " > 0x00 = maps to 0x40 = @ " > 0x01 = maps to 0x41 = A " > 0x02 = maps to 0x42 = B " > 0x03 = maps to 0x43 = C " > ... " > 0x1A = maps to 0x5A = Z " > 0x1B = maps to 0x5B = [ " > 0x1C = maps to 0x5C = \ " > 0x1D = maps to 0x5D = ] " > 0x1E = maps to 0x5E = ^ " > 0x1F = maps to 0x5F = _ "map @ :s/^#//$ " for dvorak on the typematrix "noremap d h "noremap h j "noremap t k "noremap n l "noremap k d "noremap l n "noremap j t "noremap ^Wd ^Wh "noremap ^Wh ^Wj "noremap ^Wt ^Wk "noremap ^Wn ^Wl: " "map , :noh "map i "map :w:make "map :!./program "map q :q "map Q :qa "o d h "no h j "no t k "no n l "no s : "no S : "no j d "no l n "no L N ""Added benefits "no N "no T "no H 8 "no T 8 "no D