Skip to content

Instantly share code, notes, and snippets.

@BugRoger
Created March 3, 2013 19:34
Show Gist options
  • Save BugRoger/5077869 to your computer and use it in GitHub Desktop.
Save BugRoger/5077869 to your computer and use it in GitHub Desktop.
Make console Vim play nice with iTerm2
set nocompatible
set clipboard=unnamed
if has('mouse')
set mouse=a
if exists('$ITERM_PROFILE')
autocmd VimEnter * set ttymouse=xterm2
autocmd FocusGained * set ttymouse=xterm2
autocmd BufEnter * set ttymouse=xterm2
endif
endif
if exists('$ITERM_PROFILE')
let &t_ti = &t_ti . "\e[?2004h"
let &t_te = "\e[?2004l" . &t_te
function XTermPasteBegin(ret)
set pastetoggle=<Esc>[201~
set paste
return a:ret
endfunction
map <expr> <Esc>[200~ XTermPasteBegin("i")
imap <expr> <Esc>[200~ XTermPasteBegin("")
vmap <expr> <Esc>[200~ XTermPasteBegin("c")
cmap <Esc>[200~ <nop>
cmap <Esc>[201~ <nop>
endif
if exists('$ITERM_PROFILE')
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment