I'm using vim on a shared Bluehost server. When I try to type , Vim inserts �~@~R. And when I try to type , Vim inserts �~@~S.

The problem is not specific to any particular file. It seems to happen in every file.

I tried logging out and using vim outside the server, and this time I could type medium and long dashes with no problem. So the problem is with Bluehost.

Does anyone know a solution? I suspect it involves adding something to the .vimrc file.

More details:

It only happens in Vim, not the command line.

I'm not using a graphical vim.

If I type :lang I get 'Current language: "C"'.

If I call vim with LC_ALL=C vim foo then the problem still happens.

Edit: I've found that if I enter set encoding=utf-8 then the problem is solved, at least temporarily.

  • 3
    Please edit your question and add some details. Is this only in vim or do you also see it on the command line? Is this a graphical environment? A graphical vim? What is the output of locale?
    – terdon
    Mar 11 '20 at 13:26
  • 1
    Open vim and run: :lang. Could you share the output? edit the question, don't add it in the comments. Also, does this happen if you call vim like this: LC_ALL=C vim foo? Mar 11 '20 at 13:45

Okay, I think the solution is to change the Vim's encoding by opening .vimrc, entering

set encoding=utf-8
set fileencoding=utf-8

and then saving the file.

  • 3
    You cal always run :set fileencoding to see the buffers encoding. Kudos! Mar 11 '20 at 14:12

put that into your .vimrc

set encoding=utf-8

Like this vim.stackexchange says in Specify UTF-8 encoding in Vimrc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.