Is it possible to map dead keys (accents) in Normal mode?

479 views
Skip to first unread message

Alexey

unread,
Dec 28, 2013, 4:35:08 AM12/28/13
to vim...@googlegroups.com
Hello,

i am using a Canadian Qwerty keyboard layout with dead keys for entering "^" and "¨" accents. For example, typing what would be "[o" in US Qwerty produces "ô".

Is it possible to map a dead key in Vim (in Normal mode for example)? I would like to remap the keyboard so that pressing the US Qwerty <[> key acts as "[" even in Canadian layout.

Thanks,

Alexey.

Tony Mechelynck

unread,
Dec 28, 2013, 6:05:29 AM12/28/13
to vim...@googlegroups.com
It is not possible to map only the dead key, because when you hit it the
keyboard interface (part of your OS or of X11 or…) sends nothing to Vim,
it waits until you hit the next key. You can map â ê î ô û ŷ or even, if
your keyboard will generate them, ĉ ĝ ĥ ĵ ŝ, as well as all their
uppercase counterparts. I don't know what Canadian QWERTY looks like,
but French and Belgian AZERTY have the o two keys left of the dead-key
circumflex and diaeresis, so it ought to be rather easy to produce ô or
Ö. Or maybe hitting the dead-circumflex twice will produce a
spacing-circumflex? With me (with fr_BE keyboard and UTF-8 locale on
Linux) it does.

Here, [ (which is not a dead key) is AltGr+deadkey-^, ] is AltGr+$ (just
to the right of the dead key), and for Ctrl-] (which is used a lot in
Vim) rather than Ctrl+AltGr+$, which would be troublesome, I use the
following mappings:

:map <F9> <C-]>
:map! <F9> <C-]>


Best regards,
Tony.
--
But this has taken us far afield from interface, which is not a bad
place to be, since I particularly want to move ahead to the kludge.
Why do people have so much trouble understanding the kludge? What
is a kludge, after all, but not enough K's, not enough ROM's, not
enough RAM's, poor quality interface and too few bytes to go around?
Have I explained yet about the bytes?

Alexey

unread,
Dec 28, 2013, 8:22:58 AM12/28/13
to vim...@googlegroups.com
On Saturday, December 28, 2013 3:05:29 PM UTC+4, Tony Mechelynck wrote:
> On 28/12/13 10:35, Alexey wrote:
>
> > Hello,
>
> >
>
> > i am using a Canadian Qwerty keyboard layout with dead keys for entering "^" and "¨" accents. For example, typing what would be "[o" in US Qwerty produces "ô".
>
> >
>
> > Is it possible to map a dead key in Vim (in Normal mode for example)? I would like to remap the keyboard so that pressing the US Qwerty <[> key acts as "[" even in Canadian layout.
>
> >
>
> > Thanks,
>
> >
>
> > Alexey.
>
> >
>
>
>
> It is not possible to map only the dead key, because when you hit it the
>
> keyboard interface (part of your OS or of X11 or…) sends nothing to Vim,
>
> it waits until you hit the next key. You can map â ê î ô û ŷ or even, if

Thanks, but i do not think that Vim does not receive anything when i press a dead key: when in Insert mode i press the dead <^>, it shows "^", which turns into "ô" when i press <o>.

Alexey.

Tony Mechelynck

unread,
Dec 28, 2013, 9:12:14 AM12/28/13
to vim...@googlegroups.com
That might mean that the "dead key" feature isn't due to your keyboard
interface but to some keymap or mapping (or maybe some langmap, but
that's less likely): see (while editing the file in question)

:help 'keymap'
:verbose setl keymap?

:help 'langmap'
:verbose setl langmap?

:verbose map! <Char-0x5E>

In that case, change the keymap or mapping to remove the multikey {lhs}
starting with ^ (there should be more than one). On my system, the dead
keys happen ahead of Vim, and e.g. also when typing this email in
Mozilla SeaMonkey. See
http://users.skynet.be/antoine.mechelynck/other/keybbe.htm for details
of my keyboard layout.

IMPORTANT: DO NOT MODIFY-IN-PLACE A KEYMAP WHICH IS IN
$VIMRUNRIME/keymap/ because any upgrade could undo your changes.
Instead, copy it under another name in ~/.vim/keymap/ (on Unix) or
~/vimfiles/keymap/ (on Windows, but using Vim terminology) (while
creating any directories which don't exist yet), make the changes there,
then find where the keymap is invoked (e.g. with ":verbose setl keymap")
and invoke the new one.

See also http://vim.wikia.com/wiki/How_to_make_a_keymap


Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
58. You turn on your computer and turn off your wife.

Prakash Dongare

unread,
Feb 18, 2014, 8:53:54 AM2/18/14
to vim...@googlegroups.com

Tim Chase

unread,
Feb 18, 2014, 10:29:38 AM2/18/14
to vim...@googlegroups.com, phdo...@gmail.com
You don't give a lot of details. Vim does offer digraphs

:help digraph

which allow you to create key sequences without dead keys. You can
also enter characters in insert mode by using control+V followed by a
notation for the Unicode character you want:

:help i_CTRL-V_digit

Hopefully you find one of those two methods helpful. Otherwise, you
may have to provide more information on what you need.

-tim


Tony Mechelynck

unread,
Feb 18, 2014, 10:40:28 AM2/18/14
to vim...@googlegroups.com, phdo...@gmail.com
On 18/02/14 14:53, Prakash Dongare wrote:
>
>
>
For serious help about Vim, you'd better subscribe to the list — in
fact, you already did, since you're allowed to post — and then you can
set your list preferences to get every list post, or only digests. I
recommend "every post" for the list(s) you're really interested in.

You can write any key sequence without using a dead key, if you want, by
using mappings and keymaps, but of course you'll be limited to the
number of different keys present on your keyboard. I recommend to use
mappings when they are few, or present in any kind of file; keymaps,
when there are many of them, or they are used only in a limited number
of files.

Examples:

For all helpfiles, and any files using tags; also to terminate
abbreviations:

:map <F9> <C-]>
:map! <F9> <C-]>

For files in Cyrillic alphabet: the example shows how to do it for HTML
files by means of a modeline:

<!DOCTYPE html>
<html><head>
<!--: vim: set keymap=russian-phonetic et ts=8 sts=8 :-->
<title>whatever</title>
</head><body>
...etc.
</body></html>

where $VIM/vimfiles/keymap/russian-phonetic.vim is a keymap I wrote
myself. In fact it does use dead keys, but that's because I like them. I
suppose I might have written it differently without multibyte {lhs}es.

See
:help map.txt
:help 'keymap'
http://vim.wikia.com/wiki/How_to_make_a_keymap
:help modeline



From a philosophical point of view, however, Vim is a modal editor: any
key which changes the mode could be seen as a kind of "extended dead
key". Or conversely, a dead key could be seen as a limited kind of
mode-key, which changes the mode but only for the next key, similar to
what ctrl-O does (setting Normal mode for only one command) in Insert
mode, see ":help i_CTRL-O" (without the quotes). IOW, "philosophically",
dead keys are never very far away in Vim.


Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
87. Everyone you know asks why your phone line is always busy ...and
you tell them to send an e-mail.

Reply all
Reply to author
Forward
0 new messages