LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to make VIM display french letters? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-make-vim-display-french-letters-939207/)

WojtekO 04-11-2012 12:32 AM

How to make VIM display french letters?
 
I have some files that I'd like to be able to edit in vim, unfortunately they have some french characters in the content with accents, and vim destroys them.

I get
Quote:

une entreprise spécialisée
instead of
Quote:

une entreprise spécialisée
If I do a cat on that file, it displays the french characters OK.

I tried doing in vim:
Quote:

:set encoding=utf-8
But it had no effect.

How could I solve this issue?

Thank You

EricTRA 04-11-2012 12:52 AM

Hi,

When in vim, what's the output of the following:
Code:

:verbose set enc? tenc?
and
Code:

:lang
Kind regards,

Eric

linuxlover.chaitanya 04-11-2012 12:53 AM

See if this link helps setting up the locales in vim.

http://stackoverflow.com/questions/1...anguage-in-vim

WojtekO 04-11-2012 11:18 AM

Quote:

Originally Posted by EricTRA (Post 4649853)
Hi,

When in vim, what's the output of the following:
Code:

:verbose set enc? tenc?
and
Code:

:lang
Kind regards,

Eric

The first one returns this:
Code:

encoding=utf-8
termencoding=

And the second this:
Code:

Current language: "en_US.UTF-8"
I tried doing:
Code:

:set termencoding=utf-8
Which then displayed this:
Code:

:verbose set enc? tenc?
  encoding=utf-8
  termencoding=utf-8

But the opened document still had the broken characters.
Re-opening it, cleared the termencoding value back to blank.



Quote:

Originally Posted by linuxlover.chaitanya (Post 4649854)
See if this link helps setting up the locales in vim.

http://stackoverflow.com/questions/1...anguage-in-vim

I looked at this and it seems it's for changing vim's language for menus and messages.
I want to keep mine in english, but be able to display french characters.
Thanks

EricTRA 04-11-2012 01:42 PM

Hi,

Thanks for the feedback. And what's the output of
Code:

locale
Kind regards,

Eric

WojtekO 04-11-2012 03:49 PM

Quote:

Originally Posted by EricTRA (Post 4650391)
Hi,

Thanks for the feedback. And what's the output of
Code:

locale
Kind regards,

Eric

Here is the output:
Code:

LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

Thank You

EricTRA 04-11-2012 09:40 PM

Hi,

Very strange, I have almost the same settings and output except for the :lang in vim and I can open a document with French text without loosing any accented characters. All this using all en_US.UTF-8 with a Spanish keyboard. Can you run the file command on the file and post the output, to check what encoding the file is in?
Code:

file <yourfilewithaccents>
--EDIT--

Just found another thing that might be useful. When you have the file with the French text open in vim type the following and post the output:
Code:

:set fileencoding?
to find out which file encoding vim detects on the file.

Kind regards,

Eric

WojtekO 04-12-2012 02:53 PM

Quote:

Originally Posted by EricTRA (Post 4650706)
Hi,

Very strange, I have almost the same settings and output except for the :lang in vim and I can open a document with French text without loosing any accented characters. All this using all en_US.UTF-8 with a Spanish keyboard. Can you run the file command on the file and post the output, to check what encoding the file is in?
Code:

file <yourfilewithaccents>
--EDIT--

Just found another thing that might be useful. When you have the file with the French text open in vim type the following and post the output:
Code:

:set fileencoding?
to find out which file encoding vim detects on the file.

Kind regards,

Eric

the file command returns:
Code:

ISO-8859 text, with no line terminators
:set fileencoding? returns:
Code:

fileencoding=latin1

Thanks for pointing me to the right direction!

Code:

vim ~/.vimrc
set encoding=iso-8859-1

made it work, I can now properly see the accented characters.

Thanks again,

EricTRA 04-13-2012 12:50 AM

Hi,

Nice to hear you've got it working. Thanks for marking the thread as solved.

Kind regards,

Eric


All times are GMT -5. The time now is 02:00 PM.