History Report a problem
Article Edit this page Discussion

Generate all Unicode characters

From Vim Tips Wiki

(Redirected from VimTip576)
Jump to: navigation, search

Tip 576 Previous TipNext Tip

Created: October 5, 2003 Complexity: basic Author: maxiangjiang Minimum version: 7.0 Karma: 20/8 Imported from: Tip#576


You can generate a table of Unicode characters in Vim to see how they are displayed by your system. This may be of interest to anyone using CJK characters.

Example The following will add a table showing the characters from hex 9900 to 9fff, inclusive:

:call GenerateUnicode(0x9900, 0x9fff)

Screenshot

Image:CJK.png

[edit] How to

For this to work, you will need:

:set guifont=*         "select a suitable font
:set encoding=utf-8    "set a suitable encoding
:set ambiwidth=double  "for CJK characters (probably not needed)

Copy the following into a file, then type :so % (source current file) to define the function. Enter :new and type :call GenerateUnicode(0x9900,0x9fff) (after setting the font and encoding).

function! GenerateUnicode(first, last)
  let i = a:first
  while i <= a:last
    if (i%256 == 0)
      $put ='----------------------------------------------------'
      $put ='     0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F '
      $put ='----------------------------------------------------'
    endif
    let c = printf('%04X ', i)
    for j in range(16)
      let c = c . nr2char(i) . ' '
      let i += 1
    endfor
    $put =c
  endwhile
endfunction

[edit] See also

[edit] Comments


Rate this article:

Share this article:

Hubs Highlights International Sites Wikia messages
Entertainment
Gaming
Cartoons & Comics
Science Fiction
Hobbies
Sports
See all...
Grand Theft Auto
Pixar
Legend of Zelda Wiki
Terminator Wiki
Everquest II Wiki
Flash Gordon
German
Spanish
Chinese
Japanese
More...
Wikia is hiring for several open positions
Send this article to a friend
"Generate all Unicode characters"
 
 
Hi!

I thought you'd like this page from Wikia!

http://vim.wikia.com

Come check it out!
Send confirmation


.