Wednesday, August 22, 2012

Re: Using Alt in my keymaps and utf-8

On Wednesday, August 22, 2012 3:45:58 AM UTC-5, Erik Christiansen wrote:
> On 21.08.12 08:19, Ben Fritz wrote:
>
> > Even though Vim sees the keys as a Unicode character, pressing the
>
> > keys should still execute the mapping.
>
> >
>
> > I don't think Vim can reliably do CTRL+Alt mappings, but I believe
>
> > Alt-{key} mappings normally work fine.
>
>
>
> Mostly. Over here, with:
>
>
>
> VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Apr 18 2012 19:32:03)
>
> Included patches: 1-496
>
>
>
> these Alt mappings work for me in more cases than not:
>
>
>
> " Putting åæø and «» on Alt, is handier than digraphs:
>
> inoremap <expr> <A-a> "\uE5"
>
> inoremap <expr> <A-e> "\uE6"
>
> inoremap <expr> <A-o> "\uF8"
>
> inoremap <expr> <A-<> "\uAB"
>
> inoremap <expr> <A->> "\uBB"
>
>
>
> They work fine in insert mode, and for single character replacement,
>
> using "cl", but fail when using "r". e.g.
>
>
>
> Applying "cl<A-a>" to "x" gives å, which is correct.
>
> Applying "r<A-a>" to "x" gives á, which is wrong.
>

This is very strange, and I can duplicate it in 7.3.622.

I think the problem is that single-letter replacement with 'r' does not put you into insert mode, it's just a command that takes a letter, similar to f, F, t, and T.

I did not realize this, and probably would not have realized it, but then while searching for the behavior we're seeing, I stumbled on :help language-mapping, which notes that language maps apply to (among other things) 'the argument of the commands that accept a text character, such as "r" and "f"'.

Further, I note that while :help R says it will "enter Replace mode", :help r just says it will "replace the character under the cursor with {char}". So it looks like r doesn't really put you in any particular mode, it's just an incompletely typed command.

--
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

No comments:

Post a Comment