3

I am trying to change vim mappings for (french) accentuated characters.

à (ASCII 133) I would like it to be Alt+a
À (ASCII 183) I would like it to be Alt+Shift+a
é (ASCII 130) I would like it to be Alt+e
É (ASCII 144) I would like it to be Alt+Shift+e

I would be happy to remap the existing maps Alt+i ==> é (why is that?)
How can I get those mappings to work ?

statquant
  • 13,672
  • 21
  • 91
  • 162
  • What keyboard layout do you use? – romainl Apr 20 '13 at 11:33
  • I am using a qwerty keyboard – statquant Apr 20 '13 at 11:45
  • no... http://www.cdrummond.qc.ca/cegep/informat/professeurs/alain/files/ascii.htm – statquant Apr 20 '13 at 14:39
  • 2
    +1 @progo. ASCII is 7-bit, from 0 - 127. http://en.wikipedia.org/wiki/Ascii. There are 8-bit extensions, sometimes called 8-bit ASCII or extended ASCII, but the characters with the upper-bit set aren't defined consistently. Compare ISO-8859-1, Win-1252 and ASCII. That chart shows ASCII as "ASCII-I" and what it calls "ASCII-II" are characters with the upper-bit set, AKA, "extended". – the Tin Man Apr 20 '13 at 21:47
  • Relevant: [The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)](http://www.joelonsoftware.com/articles/Unicode.html) (also includes info about ascii, obviously). – timss Apr 23 '13 at 02:20
  • sorry but any idea about the question itself ? – statquant Apr 23 '13 at 07:56
  • At a guess, Alt-i maps to é instead of í because alt-e is already mapped to open the edit menu, and so it couldn't be used for é. And rightly or wrongly, someone felt it was more important to have é than í. – Ben Aveling Feb 11 '23 at 13:38

1 Answers1

2

mapping works for theses chars, and the question is about the alt key, which may not work when the terminal prefixes the character with an ESC character. type :help map-alt-keys for more informations on that.

I just tried in xterm and theses mapping worked:

:imap <A-a> à
:imap <A-A> À
:imap <A-e> é
:imap <A-E> É

And also, for changing default mapping to another, use "remap" instead of map :

:iremap <A-i> whatever 

Edit : see also Alt key shortcuts not working on gnome terminal with Vim

Community
  • 1
  • 1
Asenar
  • 6,732
  • 3
  • 36
  • 49
  • How about the other way around? I am trying to map combinations with the accented keys to something else, without success. For example, how would you map `` ? – Tropilio Apr 13 '20 at 10:37
  • @Tropilio currently I'm using `Qwerty Lafayette` layout, which is great to use to code with vim and to write properly in french, and have no more accented key in direct access. But I m surprised the other way doesn't work. Maybe it's depends of the filetype or encoding you use for your .vimrc – Asenar Apr 13 '20 at 10:49