sponsor Vim development Vim logo Vim Book Ad

unicodeswitch.vim : Vim file plugin for editing files with unicode codes.

 script karma  Rating 28/15, Downloaded by 3721  Comments, bugs, improvements  Vim wiki

created by
Roger Pilkey
 
script type
ftplugin
 
description
Vim file plugin for editing files with unicode codes.

It changes all of the codes to the accented characters for viewing, and turns all accented characters into the code when writing.

e.g. it changes \u00E9 to é when viewing, and puts \u00E9 when writing (java-style encoding). Set g:ucs_encode_java (in your .vimrc file)

By default, it works for all the accented characters in the Unicode Latin-1 supplement, but you can quickly change it for your needs.

You can also set it to work with html encoding (&#nnn;). Set g:ucs_encode_html (in your .vimrc file)

You can also set it to convert accented characters to octal encoding ( \340 ). Set g:ucs_encode_octal in your
.vimrc file


If you want to turn the switching on and off for reading and/or writing, you can easily do so by commenting out the autocmd lines.  e.g. if you comment out the BufWrite autocmds, then you can read in \u00aa style and write out the utf encoding.  Or, you could swap the BufRead and BufWrite commands, and do the opposite transformation.

for help with the accented characters, see :help digraph

copied/mangled from vimscript #284, which does it for TeX codes
 
install details
Usage: put in your $VIMDIR/plugin directory, set one of the variables
  either
let g:ucs_encode_java = 1
or
let g:ucs_encode_html = 1
or
let g:ucs_encode_octal = 1
in your .vimrc file
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
unicodeswitch.vim 1.7 2007-05-23 6.0 Roger Pilkey added octal ( \233 )switch, fixed up the html switch
unicodeswitch.vim 1.6 2004-06-01 6.0 Roger Pilkey bugfix: correct the hex char match variable to only match up to 4 chars.
unicodeswitch.vim 1.5 2004-04-29 6.0 Roger Pilkey fix for higher numbered chars (above \u00ff)
unicodeswitch.vim 1.4 2004-02-19 6.0 Roger Pilkey Same as 1.3, but with unix line endings
unicodeswitch.vim 1.3 2004-02-19 6.0 Roger Pilkey added html-style encoding (&#nnn;) and made the script more modular
unicodeswitch.vim 1.2 2004-02-12 6.0 Roger Pilkey fix write error, oops.
unicodeswitch.vim 1.1 2004-02-12 6.0 Roger Pilkey Initial upload
ip used for rating: 142.132.191.50

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github