7

I'm running a Vimscript that retrieves the result of a message and redirects it to a vimscript variable. When the contents of the vimscript variable are displayed, it has a ^@ in it. What does that represent and how can I get rid of it?

1 Answer 1

10

^@, if you look at man ascii, is the ASCII NUL character. And from the help:

Technical detail:               *NL-used-for-Nul*
<Nul> characters in the file are stored as <NL> in memory.  In the display
they are shown as "^@".  The translation is done when reading and writing
files.  To match a <Nul> with a search pattern you can just enter CTRL-@ or
"CTRL-V 000".  This is probably just what you expect.  Internally the
character is replaced with a <NL> in the search pattern.  What is unusual is
that typing CTRL-V CTRL-J also inserts a <NL>, thus also searches for a <Nul>
in the file.  {Vi cannot handle <Nul> characters in the file at all}

You should look at eliminating it from the source. If that's not an option, do, using <c-@> as given in the docs:

:s/^@//g

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.