Vim Tips Wiki

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

Revision as of 19:11, May 18, 2009 by (Talk)

1,619pages on
this wiki
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


Around Wikia's network

Random Wiki