Vim Tips Wiki
(Change to TipImported template + severe manual clean)
(→‎Comments: mention :behave and two settings)
 
(4 intermediate revisions by 3 users not shown)
Line 9: Line 9:
 
|version=6.0
 
|version=6.0
 
|rating=3/3
 
|rating=3/3
  +
|category1=Terminals
  +
|category2=
 
}}
 
}}
I like the Windows default behavior (ctrl-c for copy, ctrl-v for paste, etc) even when I'm running vimon 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.
+
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.
   
 
<pre>
 
<pre>
 
" make arrow keys work in visual mode
 
" make arrow keys work in visual mode
vmap &lt;ESC&gt;OA k
+
vmap <Esc>OA k
vmap &lt;ESC&gt;OB j
+
vmap <Esc>OB j
vmap &lt;ESC&gt;OC l
+
vmap <Esc>OC l
vmap &lt;ESC&gt;OD h
+
vmap <Esc>OD h
 
" simulate shift-arrows (select block in windows) with control-arrows
 
" simulate shift-arrows (select block in windows) with control-arrows
inoremap &lt;ESC&gt;[A &lt;C-O&gt;vk
+
inoremap <Esc>[A <C-O>vk
vnoremap &lt;ESC&gt;[A k
+
vnoremap <Esc>[A k
inoremap &lt;ESC&gt;[B &lt;C-O&gt;vj
+
inoremap <Esc>[B <C-O>vj
vnoremap &lt;ESC&gt;[B j
+
vnoremap <Esc>[B j
inoremap &lt;ESC&gt;[C &lt;C-O&gt;vl
+
inoremap <Esc>[C <C-O>vl
vnoremap &lt;ESC&gt;[C l
+
vnoremap <Esc>[C l
inoremap &lt;ESC&gt;[D &lt;C-O&gt;vh
+
inoremap <Esc>[D <C-O>vh
vnoremap &lt;ESC&gt;[D h
+
vnoremap <Esc>[D h
 
</pre>
 
</pre>
   
 
==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, 3 March 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

Comments[]

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)