Wikia

Vim Tips Wiki

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

Edit

Back to page

(Comments: mention :behave and two settings)
 
Line 32: Line 32:
   
 
==Comments==
 
==Comments==
  +
I have learnt about ":behave" today, although all I wanted is probably:
  +
  +
<pre>
  +
set keymodel=behave
  +
set selectmode=key
  +
</pre>
  +
  +
":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.
  +
  +
--[[User:Blueyed|Blueyed]] 21:42, March 3, 2011 (UTC)

Latest revision as of 21:42, March 3, 2011

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