I'm using VIM through PuTTY to work on my development server, but it gets rather difficult when I have to work on files containing characters like those mentioned in the title. Not only does it make VIM look like this
Denne applikasjonen krever at Javascript er aktivert. Bruk en nettleser som støtter JavaScript eller aktiver JavaScript i din nåværende nettleser.
But also it completely f*cks VIM up, making the visual caret sitting somewhere completely random relative to where text appears when I'm typing.
The files I'm editing uses ISO-8859-1 encoding
root@foo:~/www/pltest# file --mime-encoding index.php
index.php: iso-8859-1
And PuTTY is set to expect ISO-8859-1 in Settings->Window->Translation. So the only issue can be Debian. If I try typing any of the above characters into the console, random appears:
root@foo:~/www/pltest# ���������
Any idea how I can get Debian to allow ISO-8859-1 symbols?
Solved it (Partly)! Apparently displaying the symbols was as simple as printing out /etc/locale.alias, finding my locale in the list and setting the corresponding language code (in my case nb_NO.ISO-8859-1) to the LANG environment variable. However, I'm still not able to type the characters into the PuTTY window. Any time I try I hear a windows error 'ding'.
Any ideas?
In order for non-ASCII characters to work, all the programs involved must use the same character encoding. The encoding needs to be set:
Then using non-ASCII on the console should work.
The settings for vim are (mostly) independent of this. vim has its own internal setting for the encoding of the files it edits, and will automatically re-encode text to be suitable for the system settings (i.e. the locale set using LANG).
To address your problem:
You have apparently taken care of 1) & 2), by setting the same encoding in Putty and using LANG. Now editing a file with non-ASCII characters should work in vim, provided vim knows which encoding the file has (either by autodetection, or by doing a
:set fileencoding=UTF-8
etc. in vim).As to "getting a ding when typing non-ASCII characters": You might need to put
set input-meta on
into your~/.inputrc
(this tells the readline library and thus bash that you want to type non-ASCII stuff) - but most modern Linux distros should no longer need this.Try to see whether other programs like vim accept non-ASCII stuff - that should tell us where the problem is.
A final remark:
While setting the locale to use ISO 8859-1 certainly works, it is usually better in the long term to use UTF-8. UTF-8 works for just about any language, not just western languages, and is quickly becoming the standard on modern Linux distros.
Note that you can still work with ISO-encoded files in vim, as vim can transcode automatically (it will often even auto-detect that the file is not in UTF-8).
Okay, so I'm having the same problem trying to input non-ASCII characters into Putty on a Debian-based system (Ubuntu Server). My fix works completely and is as follows:
1) Changed character set to UTF-8 in Putty under Settings->Window->Translation
2) Confirmed that $LANG environment variable is set to en_us.UTF-8 on the server
3) Created ~/.inputrc with the following options:
4) Log out, log back in (not sure if this is necessary)
5) Now I can copy/paste non-ASCII chars into the terminal and I can successfully use the meta key to manually type in chars like: ƒ,å,Ü...
Please see the following 'manpage' which describes the options that I used in step 3 in more detail: http://www.gnu.org/software/bash/manual/html_node/Readline-Init-File-Syntax.html
Hope this helps somebody. Cheers.