Skip to content

Instantly share code, notes, and snippets.

@echristopherson
Created April 2, 2011 05:47
Show Gist options
  • Save echristopherson/899266 to your computer and use it in GitHub Desktop.
Save echristopherson/899266 to your computer and use it in GitHub Desktop.
set nocompatible
set hidden
" Create a key code for meta+supplied character, if in a terminal. (Not
" necessary in the GUI.)
function! MakeMetaCharacter(char)
if !has('gui_running')
if a:char == ">"
" Huge kludge! set can't deal directly with >, since it confuses it
" with the end delimiter (even if you use a backslash). This also
" requires referring to M-> as Char-0xbe (see below).
exec "set <Char-0xbe>=\<Esc>" . a:char
else
exec "set <A-" . a:char . ">=\<Esc>" . a:char
endif
endif
endfunction
" This part is all commented out because it was a huge kludge and after all
" that work I couldn't get it to work with Cmd in MacVim GUI!
" Switch buffers with Cmd+ or Opt+</>
call MakeMetaCharacter('<')
noremap <A-<> :bN<CR>
noremap <D-<> :bN<CR>
noremap! <A-<> <C-o>:bN<CR>
noremap! <D-<> <C-o>:bN<CR>
" Huge kludge! 0xbe is meta->; we can't use <A-\>> because of the way
" MakeMetaCharacter deals with >, and MakeMetaCharacter can't deal with > in a
" normal way because it confuses it with the end delimiter.
call MakeMetaCharacter('>')
noremap <Char-0xbe> :bn<CR>
" The following causes noremap to assign Ü> to :bn<CR> !
noremap <A-\>> :bn<CR>
" The following causes noremap to assign <D-Bslash>> to :bn<CR> !
noremap <D-\>> :bn<CR>
noremap! <Char-0xbe> <C-o>:bn<CR>
noremap! <A-\>> <C-o>:bn<CR>
noremap! <D-\>> <C-o>:bn<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment