""" Modifier Setup: Alt and Mod4 " http://vim.wikia.com/wiki/Fix_meta-keys_that_break_out_of_Insert_mode " http://vim.wikia.com/wiki/Mapping_fast_keycodes_in_terminal_Vim " Set value of keycode or map in all modes {{{1 function! s:Setmap(map, seq) try " Some named values can be `set' execute 'set ' . a:map . '=' . a:seq catch " The rest can simply be mapped execute 'map ' . a:seq . ' ' . a:map execute 'map! ' . a:seq . ' ' . a:map endtry endfunction let namedkeys = { \ ' ': 'Space', \ '\': 'Bslash', \ '|': 'Bar', \ '<': 'lt' \ } " Map {Alt,Mod4} + ASCII printable chars {{{1 for n in range(0x20, 0x7e) let char = nr2char(n) let key = char if has_key(namedkeys, char) let char = namedkeys[char] let key = '<' . char . '>' endif " Escaped Meta (i.e. not 8-bit mode) " * Esc-[ is the CSI prefix (Control Sequence Introducer) " * Esc-O is the SS3 prefix (Single Shift Select of G3 Character Set) if char !=# '[' && char !=# 'O' call s:Setmap('', "\" . key) endif " Super / Mod4 " * Assumes terminal sends \033\007 as the Mod4 prefix. This can be " accomplished in rxvt-unicode using the keysym-list extension: " " ~/.Xdefaults: " URxvt.keysym.Mod4-0x20: list \033\007 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ " " Note that literal tab characters are used as delimiters as the " resource argument contains a list of all printable ASCII characters. call s:Setmap('<4-' . char . '>', "\\" . key) endfor unlet namedkeys n char key """ Special Keys {{{1 " Backspace call s:Setmap("", "\") call s:Setmap("", "\") " Return call s:Setmap("", "\\") call s:Setmap("<4-CR>", "\\\") " Backslash call s:Setmap("", "\\\") " Arrow keys if exists('$TMUX') call s:Setmap("", "\[A") call s:Setmap("", "\[B") call s:Setmap("", "\[C") call s:Setmap("", "\[D") else call s:Setmap("", "\Oa") call s:Setmap("", "\Ob") call s:Setmap("", "\Oc") call s:Setmap("", "\Od") endif call s:Setmap("", "\[a") call s:Setmap("", "\[b") call s:Setmap("", "\[c") call s:Setmap("", "\[d") call s:Setmap("", "\") call s:Setmap("", "\") call s:Setmap("", "\") call s:Setmap("", "\") call s:Setmap("<4-Up>", "\\\a") call s:Setmap("<4-Down>", "\\\b") call s:Setmap("<4-Right>", "\\\c") call s:Setmap("<4-Left>", "\\\d") call s:Setmap("<4-S-Up>", "\\\A") call s:Setmap("<4-S-Down>", "\\\B") call s:Setmap("<4-S-Right>", "\\\C") call s:Setmap("<4-S-Left>", "\\\D") delfunction s:Setmap