10
4

2 回答 2

10

I just found this solution:

In insert mode, press Ctrl-R ="\xe2\x82\xa9" Enter.

I'd like to know about any other (shorter?) methods, though.

于 2012-08-04T23:40:53.390 回答
6

Same solution with a twist of automation to help remember it:

command! -nargs=* UTF8 call EncodeUTF8(<f-args>)
fun! EncodeUTF8(...)
   let utf8str = ""
   for i in a:000
      let utf8str .= "\\x" . i
   endfor
   exe "norm i" . eval("\"".utf8str."\"")
endfun

Now you can :UTF8 e2 82 a9

You can also type this particular character with <C-k>W=. See :help digraph-table-mbyte.

Note that you can also get information about a character with ga and g8 in normal mode. So it might be easier to just do <C-r>="\xe2\x82\xa9" once and then do ga to get the code-point.

于 2012-08-05T01:03:06.953 回答