Hi,
how are you all using digraphs? I have read :h digraph.txt and I know
how to enter them but how do you find the digraph, if you only know
the Character or maybe the decimal code number? I am using utf-8
encoding and I find it awkward and uneasy to scan the output of
:digraphs for the desired letter.
My question is, how do you determine the digraphs, if you only know
the letter? Do you all have a copy of RFC1345 beside you and look the
code point up?
After thinking a while, I came up with the following function to look
up the character by parsing the output of :digraphs
,----
| function! GDigraph(arg)
| let o...@a
| redir @a
| silent digraphs
| redir end
| let list = split(@a, '..\s\+.\{1,2}\s\+\d\+\zs\(\s\+\|\n\)')
| let @a=old
| if (strlen(substitute(a:arg, ".", "x", "g")) == 1)
| let search=char2nr(a:arg)
| else
| let search=a:arg
| endif
| let pat = '\<' . search . '\>$'
|
| let i=1
| let idx=match(list,pat)
| while ( idx >= 0)
| if (exists("b"))
| let b.="\n" . list[idx]
| else
| let b=list[idx]
| endif
| let i+=1
| let idx=match(list,pat,0,i)
| endwhile
| redraw
| return exists("b")?printf("%s",b):"nothing found!"
| endfu
|
| command! -nargs=1 GetDigraph :echo GDigraph(<q-args>)
`----
This function handles either a decimal Code number or the character
itself and outputs the desired digraph if it finds one
(e.g. I can either type
:GetDigraph ¹
or
:GetDigraph 185
and it will return:
1S ¹ 185
11 ¹ 185
The first form is useful for copy and pasting in the desired letter
from e.g. a web browser, while the second can help you, if you only
know the code number of the letter.
Is there an easier way to determine the desired digraph without
parsing :digraphs by using :redir?
regards,
Christian
--
:wq
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---