Wikia

Vim Tips Wiki

Changes: View character class

Edit

Back to page

(Move categories to tip template)
(Remove html character entities)
 
Line 20: Line 20:
 
let pat = '[[:' . @" . ':]]'
 
let pat = '[[:' . @" . ':]]'
 
let i = 0
 
let i = 0
while i < 256
+
while i < 256
 
let ch = nr2char(i)
 
let ch = nr2char(i)
 
if ch =~ pat | echon ch . '(' . i . ')' . "\t" | endif
 
if ch =~ pat | echon ch . '(' . i . ')' . "\t" | endif
Line 26: Line 26:
 
endwhile
 
endwhile
 
endfun
 
endfun
nn cc :call &lt;SID&gt;Show()&lt;Cr&gt;
+
nn cc :call <SID>Show()<Cr>
 
</pre>
 
</pre>
   
 
==Comments==
 
==Comments==
 
----
 

Latest revision as of 08:50, September 29, 2008

Tip 502 Printable Monobook Previous Next

created July 2, 2003 · complexity intermediate · author beo · version 6.0


This one shows the definition of a predefined character class. ([:alpha:], [:graph:] etc.) The cursor is assumed to point to the name of the character class one wants to examine. Press "cc".

fun! s:Show()
  norm! viwy
  echo 'class [:' . @" . ':]' . "\n"
  let pat = '[[:' . @" . ':]]'
  let i = 0
  while i < 256
    let ch = nr2char(i)
    if ch =~ pat | echon ch . '(' . i . ')' . "\t" | endif
    let i = i + 1
  endwhile
endfun
nn cc :call <SID>Show()<Cr>

CommentsEdit

Around Wikia's network

Random Wiki