Vim Tips Wiki
m (One call to generate all unicode "characters" from within vim moved to Generate all Unicode characters: Page moved by JohnBot to improve title)
(Change to TipImported template + severe manual clean)
Line 1: Line 1:
 
{{review}}
 
{{review}}
  +
{{TipImported
{{Tip
 
 
|id=576
 
|id=576
  +
|previous=575
|title=one call to generate all unicode "characters" from within vim
 
  +
|next=577
|created=October 5, 2003 17:16
+
|created=October 5, 2003
 
|complexity=basic
 
|complexity=basic
|author=maxiangjiang--AT--hotmail.com
+
|author=maxiangjiang
 
|version=6.0
 
|version=6.0
 
|rating=20/8
 
|rating=20/8
|text=
 
 
 
This is a small function to generate all unicode "characters".
 
 
It might be interesting to those who are familiar with CJK.
 
 
 
 
I modified Frank's idea, http://groups.yahoo.com/group/vim/message/43907,
 
 
with a neat format. (Thank you, Frank)
 
 
 
 
Tony Mechelynck offered a great tip as how to work with utf-8 in
 
 
http://vim.sourceforge.net/tip_view.php?tip_id=246
 
 
 
 
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
 
function! GenerateUnicode()
 
 
let i = 0
 
 
while i <= 16*16*16*16
 
 
let n = i
 
 
let j = 0
 
 
let h = ""
 
 
while n
 
 
let h = '0123456789ABCDEF'[n%16].h
 
 
let n = n/16
 
 
endwhile
 
 
let c = h.' '
 
 
while j<16
 
 
let u = i+j
 
 
let c = c.nr2char(u).' '
 
 
let j = j+1
 
 
endwhile
 
 
$put = c
 
 
let i = i+16
 
 
if (i%(16*16) == 0)
 
 
$put='----------------------------------------------------'
 
 
$put=' 0 1 2 3 4 5 6 7 8 9 A B C D E F '
 
 
$put='----------------------------------------------------'
 
 
endif
 
 
endwhile
 
 
endfunction
 
 
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
 
 
 
 
 
 
 
}}
 
}}
 
This is a small function to generate all Unicode "characters". It might be interesting to those who are familiar with CJK.
   
  +
<pre>
== Comments ==
 
 
function! GenerateUnicode()
 
let i = 0
 
while i &lt;= 16*16*16*16
 
let n = i
 
let j = 0
 
let h = ""
 
while n
 
let h = '0123456789ABCDEF'[n%16].h
 
let n = n/16
  +
endwhile
 
let c = h.' '
 
while j&lt;16
 
let u = i+j
 
let c = c.nr2char(u).' '
 
let j = j+1
  +
endwhile
 
$put = c
 
let i = i+16
 
if (i%(16*16) == 0)
 
$put='----------------------------------------------------'
 
$put=' 0 1 2 3 4 5 6 7 8 9 A B C D E F '
 
$put='----------------------------------------------------'
  +
endif
  +
endwhile
 
endfunction
  +
</pre>
   
 
A screen shot is at http://www.clarkson.edu/~maxi/unicode.gif
Here is the screen shot:
 
   
 
==Comments==
http://www.clarkson.edu/~maxi/unicode.gif
 
 
maxiangjiang--AT--hotmail.com
 
, October 5, 2003 18:15
 
----
 
hi
 
which font you using to display??
 
i cant get these foreign chars to display..
 
using winxp..
 
plus.. another note.. why the "freemono" fonts (http://www.nongnu.org/freefont/) are not available to select
 
in windows.. but available in *nixes..??
 
   
'''Anonymous'''
 
, February 18, 2006 5:43
 
 
----
 
----
<!-- parsed by vimtips.py in 0.484955 seconds-->
 

Revision as of 07:30, 4 November 2007

Tip 576 Printable Monobook Previous Next

created October 5, 2003 · complexity basic · author maxiangjiang · version 6.0


This is a small function to generate all Unicode "characters". It might be interesting to those who are familiar with CJK.

function! GenerateUnicode()
  let i = 0
  while i <= 16*16*16*16
    let n = i
    let j = 0
    let h = ""
    while n
      let h = '0123456789ABCDEF'[n%16].h
      let n = n/16
    endwhile
    let c = h.' '
    while j<16
      let u = i+j
      let c = c.nr2char(u).' '
      let j = j+1
    endwhile
    $put = c
    let i = i+16
    if (i%(16*16) == 0)
      $put='----------------------------------------------------'
      $put=' 0 1 2 3 4 5 6 7 8 9 A B C D E F '
      $put='----------------------------------------------------'
    endif
  endwhile
endfunction

A screen shot is at http://www.clarkson.edu/~maxi/unicode.gif

Comments