Wikia

Vim Tips Wiki

Mimic shift-arrow to select text in terminals without shift-arrow

Talk0
1,613pages on
this wiki

Redirected from VimTip537

Tip 537 Printable Monobook Previous Next

created August 21, 2003 · complexity intermediate · author urlwolf · version 6.0


I like the Windows default behavior (ctrl-c for copy, ctrl-v for paste, etc) even when I'm running vim on a unix terminal. However, using mswin doesn't give the right "mark block" behavior in the terminal I use (putty). This may hold true for other Xterm emulators: the shift-arrows (mark block) don't work because shift-arrow sends exactly the same signal as just arrows. I have some maps that fix this by assigning some imaps and vmaps to the combination of ctrl-arrows.

" make arrow keys work in visual mode
vmap <Esc>OA k
vmap <Esc>OB j
vmap <Esc>OC l
vmap <Esc>OD h
" simulate shift-arrows (select block in windows) with control-arrows
inoremap <Esc>[A <C-O>vk
vnoremap <Esc>[A k
inoremap <Esc>[B <C-O>vj
vnoremap <Esc>[B j
inoremap <Esc>[C <C-O>vl
vnoremap <Esc>[C l
inoremap <Esc>[D <C-O>vh
vnoremap <Esc>[D h

CommentsEdit

I have learnt about ":behave" today, although all I wanted is probably:

set keymodel=behave
set selectmode=key

":behave mswin" might work great, albeit the strange name of it. I have not added anything of this to my vimrc yet, but I tend to go with ":behave mswin" for now.

--Blueyed 21:42, March 3, 2011 (UTC)

Around Wikia's network

Random Wiki