Vim Tips Wiki

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

Redirected from VimTip537

1,624pages on
this wiki
Add New Page
Talk0 Share
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


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)

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random Wiki