├── autoload └── characterize.vim ├── doc └── characterize.txt └── plugin └── characterize.vim /doc/characterize.txt: -------------------------------------------------------------------------------- 1 | *characterize.txt* Unicode character metadata 2 | 3 | Author: Tim Pope 4 | Repo: https://github.com/tpope/vim-characterize 5 | License: Same terms as Vim itself (see |license|) 6 | 7 | This plugin is only available if 'compatible' is not set. 8 | 9 | SUMMARY *characterize* 10 | 11 | Provides one map and one command. 12 | 13 | *characterize-ga* 14 | ga Print the unicode value of the character under the 15 | cursor in decimal, hexadecimal and octal, along with 16 | the unicode name, HTML entity, Emoji code, and any 17 | available |digraphs|. 18 | 19 | *:Characterize* 20 | :Characterize [char] Like |characterize-ga|, but you can optionally give a 21 | character to act on instead of the one under the 22 | cursor. 23 | 24 | vim:tw=78:et:ft=help:norl: 25 | -------------------------------------------------------------------------------- /plugin/characterize.vim: -------------------------------------------------------------------------------- 1 | " characterize.vim - Unicode character metadata 2 | " Maintainer: Tim Pope 3 | " Version: 1.1 4 | " GetLatestVimScripts: 4410 1 :AutoInstall: characterize.vim 5 | 6 | if exists("g:loaded_characterize") || v:version < 700 || &cp 7 | finish 8 | endif 9 | let g:loaded_characterize = 1 10 | 11 | function! s:info(arg) abort 12 | let char = a:arg 13 | let nl_is_null = 0 14 | if empty(char) 15 | let char = getline('.')[col('.')-1:-1] 16 | let nl_is_null = 1 17 | elseif char =~# '^\\[xuU]\=0\+\x\@!' 18 | let char = "\n" 19 | let nl_is_null = 1 20 | elseif char =~# '^\\.' 21 | try 22 | let char = eval('"' . char . '"') 23 | catch 24 | endtry 25 | endif 26 | let char = matchstr(char, '.') 27 | if empty(char) 28 | return 'NUL' 29 | endif 30 | let charseq = char 31 | let outs = [] 32 | while !empty(charseq) 33 | if nl_is_null && charseq =~# "^\n" 34 | let nr = 0 35 | elseif nl_is_null && charseq =~# "^\r" && &fileformat ==# 'mac' 36 | let nr = 10 37 | else 38 | let nr = char2nr(charseq) 39 | endif 40 | let char = nr < 32 ? '^'.nr2char(64 + nr) : nr2char(nr) 41 | let charseq = strpart(charseq, nr ? len(nr2char(nr)) : 1) 42 | let out = '<' . (empty(outs) ? '' : ' ') . char . '> ' . nr 43 | if nr < 256 44 | let out .= printf(', \%03o', nr) 45 | endif 46 | let out .= printf(', U+%04X', nr) 47 | let out .= ' '.characterize#description(nr, '') 48 | for digraph in characterize#digraphs(nr) 49 | let out .= ", ".digraph 50 | endfor 51 | for emoji in characterize#emojis(nr) 52 | let out .= ', '.emoji 53 | endfor 54 | call add(outs, out) 55 | endwhile 56 | let str = join(outs, ' ') 57 | let entities = characterize#html_entities(char) 58 | if empty(entities) 59 | return str 60 | elseif len(outs) == 1 61 | return str . ', ' . entities 62 | else 63 | return str . ' | ' . entities 64 | endif 65 | endfunction 66 | 67 | command! -bar -nargs=? Characterize echo info() 68 | 69 | nnoremap