Sunday, January 31, 2010

Re: Control-

On Sun, 31 Jan 2010, Gary Johnson wrote:

> On 2010-01-30, Paul wrote:
> > On Tue, Jan 26, 2010 at 11:35:08AM -0800, Gary Johnson wrote:
> > >One solution is to set the value of TERM to one that vim recognizes
> > >and whose terminfo database accurately reflects the capabilities of
> > >your terminal. I think the ones vim recognizes are:
> > >
> > > xterm
> > > nxterm
> > > kterm
> > > mlterm
> > > rxvt
> >
> > I'm using mlterm, but XTERM is set to 'xterm'. When I set it to
> > 'mlterm', I get the same behaviour. It works when I run vim from
> > xterm, though, both when TERM is 'xterm' and 'mlterm'.
>
> I assume that "XTERM" is a typo and that you meant "TERM".
>
> > >Another solution would be to map the sequences your terminal emits
> > >to the <C-Left> and <C-Right> key codes, e.g.,
> > >
> > > :cmap <Esc>[1;5D <C-Left>
> > > :cmap <Esc>[1;5C <C-Right>
> >
> > I tried it but it didn't work - same behaviour :(
>
> That suggests to me that vim is properly configuring itself to accept
> the escape sequences for those keys from both terminal types, but that
> your mlterm is emitting different sequences from the ones that vim
> expects from an mlterm. Try this. Open a new buffer and enter insert
> mode. Then type Ctrl-V followed by Ctrl-Left. Type Enter, then
> Ctrl-V followed by Ctrl-Right. What do you see?
>

There was a similar thread recently on the Zsh list about the 'Home' and
'End' keys. If I'm not mistaken, Vim puts terminals into 'application'
mode, where, in mlterm, the sequences are:

(bare) (Ctrl+)
Up ^[OA ^[O1;5A
Down ^[OB ^[O1;5B
Right ^[OC ^[O1;5C
Left ^[OD ^[O1;5D
O = capital o, not zero

I found those by using 'zsh' running under 'mlterm' via:

print $terminfo[smkx] ; cat > /dev/null ; print $terminfo[rmkx]

(Without the 'smkx'/'rmkx' enter- and leave- keyboard_transmit-mode, it
emits XTerm-like sequences:)

(bare) (Ctrl+)
Up ^[[A ^[[1;5A
Down ^[[B ^[[1;5B
Right ^[[C ^[[1;5C
Left ^[[D ^[[1;5D

The upshot is that the Vim mappings the OP is looking for are:

:cmap <Esc>O1;5A <C-Up>
:cmap <Esc>O1;5B <C-Down>
:cmap <Esc>O1;5C <C-Right>
:cmap <Esc>O1;5D <C-Left>

(Then any <C-arrow> mappings should work.)

It may or may not matter, but I was using the correct TERM value
(TERM=mlterm).

--
Best,
Ben

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

No comments: