Home | Hardware | Internet News |Web Hosting |IT Management |Network Storage
LinuxPlanet
Search 
  Power Search | Tips 

 Front Door
 Discussion
 LinuxEngine
 Opinions
 Reports
 Reviews
 Tutorials
 News
 Technology Jobs

 Browse by subject.
Free Newsletter

Linux Planet
Linux Today
More Free Newsletters

Be a Commerce Partner


















internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

Print this article
Email this article

   LinuxPlanet / Tips







Turning on Unicode Support in Vim
Unicode in Vim

Juliet Kemp
Monday, June 22, 2009 05:45:18 PM

Juliet Kemp

The editor Vim supports Unicode natively. If your X or console keymap is set up to enter unicode characters via the keymap, it will work fine in Vim. Alternatively, there are two other ways of entering these characters.

The slow way is just to use their hex code. Hit Ctrl+V, then u, then type the hex code. For example, hex code 00BF will give you an inverted question mark, ¿. This is useful if you only very occasionally want to type one of these characters. Lists of UTF-8 character codes are available online.

A better bet is to set up digraphs. These enable you to type a character, backspace, then another character, and have a UTF-8 character generated. To use these, first put this line:

set digraph

in your ~/.vimrc file (or to do it temporarily, type __:set digraph__ in command mode in Vim). To show the digraphs you have set, type this in command mode:

:digraphs

After this, typing (for example) D backspace - will give you Ð.

You can set your own digraphs using:

:dig'raphs' char1char2 number

where number is the decimal representation of the hex code for the character you want. Find more information about Unicode characters and possible encodings for them (including hex, decimal, and HTML) at this very useful page. Use this on the Vim command line, or add it to your ~/.vimrc file.

If you find digraphs annoying (if you regularly have to backspace to correct single characters, you may end up inserting them by accident), type:unset digraphs in command mode (or add unset digraphs to your ~/.vimrc__ file), and use Ctrl+K char1 char2 instead of char1 backspace char2 to enter digraphs. This method is always available, even when digraphs aren't set.

Follow ServerWatch on Twitter

Article courtesy of ServerWatch





Linux is a trademark of Linus Torvalds.


internet.com home | search | help! | about us

Jupiter Online Media

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers