I'm writing a vimscript function that converts a single ASCII control-character in the range 1 - 26 (e.g.
^F) to its two-character printable representation (e.g.
Currently, I have:
func! CtrlCharStr(arg) let cntrl = matchstr(a:arg, '^[[:cntrl:]]$') let ascii = char2nr(cntrl) if ascii >= 1 && ascii <= 26 let letter = nr2char(ascii + 64) return '^'.letter else return '' endif endf
Is there a more straightforward way to do this?
The reason I'm doing this in the first place is to check whether the given character appears in
!^F, and should re-indent the current line instead of being inserted.