Tuesday, April 2, 2013

Re: Is there already a solution for mapping in Terminal (urxvt)?

For some reason, the message arrived garbled when sent in Latin1 so I'm
sending it again, but in UTF-8 this time.

On 02/04/13 22:47, Kent wrote:
> Hi everybody,
>
> I knew this is not a new topic. I had that problem years ago, tried a
> lot and finally gave up. Recently, I went through my vimrc, and found
> my very old commented out codes:
>
> "mapping <a-j> in unxvt doesn't work, gave up!!
>
>
> about 3,4 years have past, I did some tests just now, it still didn't
> work. What I want to map is simple, <a-j/k> move current line up/down.
>
> The mapping is easy. point is how to make <alt> work.
> what I tried: (e.g <a-j>)
>
> set timeout timeoutlen=1000 ttimeoutlen=100
> set <m-j>=^[j (c-v then a-j)
> inoremap <m-j> <Esc>:m+<CR>==gi
>
> this works, problem is if in Insert mode I press<esc> to back to
> normal mode and `j` to next line, vim does above mapping, which stops
> switching to Normal, but move the current line down and stay in Insert
> mode. The ttimeout=100 didn't seem to work.. no idea why.
>
> also tried :
>
> set timeout timeoutlen=1000 ttimeoutlen=100
> set <m-j>= ^[j
> imap ^[ j <m-j>
> inoremap ^[ j <Esc>:m+<CR>==gi
>
> it prints the "ê"
>
> Is there already a working solution for it?
>
> thanks
>
> Kai
>

To make Vim tell apart mappings, multibyte key codes, and successive
keypresses, see
:help 'timeout'
:help 'timeoutlen'
:help 'ttimeout'
:help 'ttimeoutlen'
:help 'showcmd'

I recommend using

:set timeout timeoutlen=5000 ttimeoutlen=100 showcmd

in your vimrc, but these values (where numbers are in milliseconds) are
what I'm comfortable with; they may vary according to your patience and
typing speed, and to the speed of your keyboard connection, so read the
help.

Note also that <Alt>+some-printable-key is stored internally as the
printable key OR 0x80, so ê (0xEA) is <Alt> + j (because j is 0x6A). See
also
:help 'esckeys'
:help :map-alt-keys


Best regards,
Tony.
--
Beware of self-styled experts: an ex is a has-been, and a spurt is a
drip under pressure.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: