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:

  1. 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).
  2. most functions return list of strings (like readfile, getline(start, end)) or take list of strings (like writefile, setline, append) treat \n (nl) null. internal representation of buffer lines, see :h nl-used-for-nul.
  3. 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

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -