special characters - How to use '^@' in Vim scripts? -
i'm trying work around problem using ^@ (i.e., <ctrl-@>
) characters in vim scripts. can insert them script, when script runs seems line truncated @ point ^@ located.
my kludgy solution far have ^@ stored in variable, reference variable in script whenever have quoted literal ^@. can tell me what's going on here? there better way around problem?
that 1 reason why never use raw special character values in scripts. while ^@
not work, string <c-@>
in mappings works expected, may use 1 of
nnoremap <c-@> {rhs} nnoremap <nul> {rhs}
it strange, cannot use <char-0x0>
here. notes null byte in strings:
- inserting null byte string truncates it: vim uses old c-style strigs end null byte, cannot appear in strings. these strings inefficient, if want generate large text, try accumulating list of lines (using
setline
fast buffer represented list of lines). - most functions return list of strings (like
readfile
,getline(start, end)
) or take list of strings (likewritefile
,setline
,append
) treat\n
(nl) null. internal representation of buffer lines, see:h nl-used-for-nul
. - if try insert
\n
character command-line, null shown (but newline). if want edit file has\n
in filename (it possible on *nix), need prepend newline backslash.
Comments
Post a Comment