Vim accented characters in text based console

1,324 views
Skip to first unread message

Luis P. Mendes

unread,
Apr 9, 2010, 7:48:54 PM4/9/10
to vim...@googlegroups.com
Hi,

I use Vim everyday, I could say at every hour :-) in X graphical mode.
$ vim --version
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Aug 24 2009 20:12:41)
Included patches: 1-245

I tried to use Vim with no X, in text base mode, but there was one
problem with accented characters. I could not use them and the ones
that where inserted before in graphical mode were like strange
characters.
Example:
ã with X, is ~a in text mode
the same with é --> 'e

I checked LC_ALL and is defined to pt_PT in either situations.
What should I correct to be able to use Vim in text mode in my
Slackware 13 64 bits box?


Luis

Tony Mechelynck

unread,
Apr 9, 2010, 9:16:43 PM4/9/10
to vim...@googlegroups.com, Luis P. Mendes
On 10/04/10 01:48, Luis P. Mendes wrote:
> Hi,
>
> I use Vim everyday, I could say at every hour :-) in X graphical mode.
> $ vim --version
> VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Aug 24 2009 20:12:41)
> Included patches: 1-245
>
> I tried to use Vim with no X, in text base mode, but there was one
> problem with accented characters. I could not use them and the ones
> that where inserted before in graphical mode were like strange
> characters.
> Example:
> � with X, is ~a in text mode
> the same with � --> 'e

>
> I checked LC_ALL and is defined to pt_PT in either situations.
> What should I correct to be able to use Vim in text mode in my
> Slackware 13 64 bits box?
>
>
> Luis
>

There seems to be something weird in the way your terminal represents
characters. What does bash answer to

echo -e '\0351'

? Mine replies with a reverse-video question mark because my terminal is
in UTF-8; if yours is in Latin1 the reply ought to be �, but if it is 'e
it shows that the terminal interprets � -> 'e after bash outputs it. (In
a UTF-8 terminal, to get � you need echo -e '\xC3\xA9' but then your
LC_CTYPE [or your LC_ALL, which overrides all other locale settings]
should be pt_PT.utf8 .)

To see all possible Portuguese locales, use

locale -a |grep ^pt

On my system, the answer is

pt_BR
pt_BR.utf8
pt_PT
pt_PT@euro
pt_PT.utf8

I'm not sure how to tweak the way your Linux terminal represents
characters above 0x7F.


Note that GNU bash's implementation of echo (as shown above) is not
POSIX-compliant. If you're using a different shell, either use bash as
an auxiliary shell, or find out if and how your implementation of echo
differs from mine.


Best regards,
Tony.
--
Malek's Law:
Any simple idea will be worded in the most complicated way.

Tony Mechelynck

unread,
Apr 10, 2010, 8:36:35 PM4/10/10
to Luis P. Mendes, Vim List
On 10/04/10 11:23, Luis P. Mendes wrote:
> 2010/4/10 Tony Mechelynck<antoine.m...@gmail.com>:

>> On 10/04/10 01:48, Luis P. Mendes wrote:
>>>
>>> Hi,
>>>
>>> I use Vim everyday, I could say at every hour :-) in X graphical mode.
>>> $ vim --version
>>> VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Aug 24 2009 20:12:41)
>>> Included patches: 1-245
>>>
>>> I tried to use Vim with no X, in text base mode, but there was one
>>> problem with accented characters. I could not use them and the ones
>>> that where inserted before in graphical mode were like strange
>>> characters.
>>> Example:
>>> ã with X, is ~a in text mode
>>> the same with é --> 'e

>>>
>>> I checked LC_ALL and is defined to pt_PT in either situations.
>>> What should I correct to be able to use Vim in text mode in my
>>> Slackware 13 64 bits box?
>>>
>>>
>>> Luis
>>>
>>
>> There seems to be something weird in the way your terminal represents
>> characters. What does bash answer to
>>
>> echo -e '\0351'
>>
>> ? Mine replies with a reverse-video question mark because my terminal is in
>> UTF-8; if yours is in Latin1 the reply ought to be é, but if it is 'e it
>> shows that the terminal interprets é -> 'e after bash outputs it. (In a
>> UTF-8 terminal, to get é you need echo -e '\xC3\xA9' but then your LC_CTYPE

>> [or your LC_ALL, which overrides all other locale settings] should be
>> pt_PT.utf8 .)
>
> I tried in both X and text console and the result is the same: 'é'
> So, this must be a vim configuration issue, I presume.
>
> Luis
>

Hm. What does vim answer to

:verbose set enc? tenc?
:lang

(I would expect encoding=Latin1, termencoding= (empty), no line saying
where either of them was set, and all language values set to pt_PT.
Anything else could put us on the right track.)

Oh, and BTW, how do you type é in Vim? What happens in Insert mode when
you hit Ctrl-V followed by 233 (two-three-three)? Or Ctrl-K then e then
an apostrophe?

Apostrophe-e sounds like a language-mapping set by the "accents" keymap. So:

:verbose setlocal keymap? imi?

in the window where you see 'e instead of é and ~a instead of ã -- what
does Vim say? And what does gvim say, which displays them correctly?


Best regards,
Tony.
--
It may be that your whole purpose in life is simply to serve as a
warning to others.

Luis P. Mendes

unread,
Apr 11, 2010, 5:57:54 AM4/11/10
to Tony Mechelynck, Vim List
Hi Tony,

thank you very much for your help and time trying to help me.

Here are the results I got from vim.

In X, vim (not gvim which I don't use) returns:
encoding=latin1
termencoding=

lang: Current language:
"LC_CTYPE=pt_PT;
LC_NUMERIC=C;
LC_TIME=pt_PT;
LC_COLLATE=pt_PT;
LC_MONETARY=pt_PT;
LC_MESSAGES=pt_
PT;LC_PAPER=pt_PT;
LC_NAME=pt_PT;
LC_ADDRESS=pt_PT;
LC_TELEPHONE=pt_PT;
LC_MEASUREMENT=pt_PT;
LC_IDENTIFICATION=pt_PT"

keymap=
iminsert=0

Ctrl-V followed by 233 é

Ctrl-K then e then an apostrophe é
and if I key: Ctrl-K then e then the accent mark followed by a space I
get a é


In text console the results are the same.

Another information:
I tried pico text editor in X, and am able to use accented characters.
In text mode console, I can't. The symptoms are identical to vim's.
To use accented characters, I just have to press the accent first (ex.
') and the base character I want accented (like e).

So, I guess I have to check my Slackware system configuration instead of vim's.


Luis

2010/4/11 Tony Mechelynck <antoine.m...@gmail.com>:

Tony Mechelynck

unread,
Apr 11, 2010, 12:28:28 PM4/11/10
to Luis P. Mendes, Vim List
On 11/04/10 11:57, Luis P. Mendes wrote:
> Hi Tony,
>
> thank you very much for your help and time trying to help me.
>
> Here are the results I got from vim.
>
> In X, vim (not gvim which I don't use) returns:

I thought you had used gvim before, with no error.

> encoding=latin1
> termencoding=
>
> lang: Current language:
> "LC_CTYPE=pt_PT;

------------^
This one specifies (system-wise) what "national settings" to use for
character sets; IIUC when Vim sees this at startup it sets 'encoding' to
latin1. ('termencoding' empty means "use 'encoding'" and is the default.)

> LC_NUMERIC=C;
> LC_TIME=pt_PT;
> LC_COLLATE=pt_PT;
> LC_MONETARY=pt_PT;
> LC_MESSAGES=pt_
> PT;LC_PAPER=pt_PT;
> LC_NAME=pt_PT;
> LC_ADDRESS=pt_PT;
> LC_TELEPHONE=pt_PT;
> LC_MEASUREMENT=pt_PT;
> LC_IDENTIFICATION=pt_PT"
>
> keymap=
> iminsert=0
>
> Ctrl-V followed by 233 é
>
> Ctrl-K then e then an apostrophe é
> and if I key: Ctrl-K then e then the accent mark followed by a space I
> get a é

Hm. Normally the accent mark followed by e (without the Ctrl-K prefix)
ought to give é then. If it doesn't, there may be something
misconfigured, either in X (for Vim in xterm, konsole, gnome-terminal
etc.) or in the kernel's keymap setting (for the Linux console). I don't
know Slackware (my Linux system is openSUSE, which is loosely based on
RedHat) so I wouldn't venture to tell you where to look for that.

>
>
> In text console the results are the same.
>
> Another information:
> I tried pico text editor in X, and am able to use accented characters.
> In text mode console, I can't. The symptoms are identical to vim's.
> To use accented characters, I just have to press the accent first (ex.
> ') and the base character I want accented (like e).
>
> So, I guess I have to check my Slackware system configuration instead of vim's.
>
>
> Luis

Well, in the meantime you can use digraphs, see
:help digraph.txt
:help digraphs-default

and in particular
Ctrl-K e apostrophe gives é (e-acute)
Ctrl-K a exclamation-mark gives à (a-grave)
Ctrl-K o question-mark gives õ (o-tilde)
Ctrl-K c comma gives ç (c-cedilla)
etc. Of course any precomposed character present on your keyboard should
normally also be usable (my Belgian keyboard has a lot of these, see
http://users.skynet.be/antoine.mechelynck/other/keybbe.htm )

Or you can use
:setlocal keymap=accents

and use the dead-key prefixes defined in that keymap: apostrophe-e means
e-acute, backtick-a means a-grave, tilde-o (with a spacing tilde) means
o-tilde (with the tilde above the o), etc.: see
:view $VIMRUNTIME/keymap/accents.vim
:help 'keymap'
:help mbyte-keymap

Of course, if you want to use an apostrophe followed by a vowel then,
you will have to either switch the keymap temporarily off beforehand
(see below), or else "break" the mapping, either by waiting for a
timeout (by default one second, see :help 'timeoutlen', but 'timeout'
[q.v.] must be on [not the default] for that) after the apostrophe, or
by inserting some "do-nothing" key-sequence after the apostrophe, for
instance <Left><Right>.
To toggle between the keymap and your "normal" Portuguese keyboard (for
Insert-Replace and Command-line modes, and the operands of Normal
commands r f F t T ), use:
- in Insert and Command-line modes: Ctrl-^
- in Normal mode: :let &imi = !&imi
see
:help i_CTRL-^
:help c_CTRL-^
:help 'iminsert'
:help 'imsearch'
I recommend to set 'imsearch' to -1 (not the default) in your vimrc, so
/ and ? search commands use the same keyboard (your usual or the keymap)
as in Insert mode at any particular time.


Best regards,
Tony.
--
"In defeat, unbeatable; in victory, unbearable."
-- Winston Curchill, of Montgomery

Luis P. Mendes

unread,
Apr 11, 2010, 12:47:23 PM4/11/10
to Tony Mechelynck, Vim List
Thank you very much,

I'll look into these issues.
Vim is definitely a world in its own!

Luis

2010/4/11 Tony Mechelynck <antoine.m...@gmail.com>:

BC

unread,
Apr 27, 2010, 2:02:58 AM4/27/10
to vim_use


On Apr 11, 12:28 pm, Tony Mechelynck <antoine.mechely...@gmail.com>
wrote:
>
> Of course, if you want to use an apostrophe followed by a vowel then,
> you will have to either switch the keymap temporarily off beforehand
> (see below), or else "break" the mapping, either by waiting for a
> timeout (by default one second, see :help 'timeoutlen', but 'timeout'
> [q.v.] must be on [not the default] for that) after the apostrophe, or
> by inserting some "do-nothing" key-sequence after the apostrophe, for
> instance <Left><Right>.


I found by accident that the simplest way to defeat the ' dead key is
just to hit it twice; that gives you the apostrophe. HItting the space
bar won't do it, unfortunately -- if it did, this would be very
comfortable for people used to the US-International keyboard layout.
But a double tap on the apostrophe works great.

I'm very grateful to learn about keymap=accents. It's much more
convenient than the Ctrl-K commands I was struggling with! Thanks.

- B

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

Subscription settings: http://groups.google.com/group/vim_use/subscribe?hl=en
Reply all
Reply to author
Forward
0 new messages