searchvimutf-8iso-8859-1

How to replace <e9> by é in vim


I want to search and replace "<e9>" by "é".

:%s/<e9>/é/g

Doesn't works but <e9> seems vim special char

/ ctrl+v xe9

find only the correct "é" but not "<e9>"

If i'm on <e9> and i type :ascii i've got this result:

<é> 233, Hexa 00e9, Octal 351

If i'm on "é" and i type :ascii i've got this result:

<é> 233, Hexa 00e9, Octal 351


Solution

  • Your text already contains the proper é character (as shown by the :ascii command), it's just that Vim doesn't display it like that. (You can verify with another text lister / editor.)

    How characters are displayed is governed by the 'isprint' option. Its help says:

    When 'encoding' is a Unicode one, illegal bytes from 128 to 255 are displayed as <xx>, with the hexadecimal value of the byte.

    So, assuming you haven't change the 'isprint' value, you likely have an issue with the detection of the encoding. Check

    :set encoding? fileencodings? fileencoding?
    

    and correct.