On Tue, 16 May 2006, Malhotra, Vijendra wrote:
I have the following mappings that work fine on vim but don't on gvim any idea
why
" Window manipulation
"Ctrl left == Ctrl W l
map ^[Oc ^Wl
" Ctrl left
map ^[Od ^Wh
" Ctrl+Down == Ctrl-W + j
map ^[Ob ^Wj
" Ctrl+Up == Ctrl-W + k
map ^[Oa ^Wk
You're mapping Vim keystrokes to shell keycodes (that aren't really
acknowledged by GVim). A better way would be to map Vim keystrokes to
Vim's internal representation of keycodes. On the first pass, we would
have:
nnoremap <C-Right> <C-w>l
nnoremap <C-Left> <C-w>h
nnoremap <C-Down> <C-w>j
nnoremap <C-Up> <C-w>k
nmap ^[Oc <C-Right>
nmap ^[Od <C-Left>
nmap ^[Ob <C-Down>
nmap ^[Oa <C-Up>
(should work in GVim at this point)
But mapping ^[O<alphabet> will cause Vim to wait everytime you press
Esc, because there's a possibility that an "O" followed by an alphabet
will come after the Esc. You won't manually type that "O" + .., of
course (but it's possible). It comes whenever you do the
Ctrl-combination in the terminal.
An improvement would be to represent the shell keycode as one of Vim's
internal representation. Then we can use 'ttimeoutlen':
set timeout timeoutlen=1000 ttimeoutlen=100
set <xF1>=^[Oc <xF2>=^[Od <xF3>=^[Ob <xF4>=^[Oa
nnoremap <C-Right> <C-w>l
nnoremap <C-Left> <C-w>h
nnoremap <C-Down> <C-w>j
nnoremap <C-Up> <C-w>k
nmap <xF1> <C-Right>
nmap <xF2> <C-Left>
nmap <xF3> <C-Down>
nmap <xF4> <C-Up>
Now Esc won't "wait".
See
:help 'ttimeoutlen'
:help <xF1>
HTH :)
--
Gerald