About: Newlines and nulls in Vim script   Sponge Permalink

An Entity of Type : owl:Thing, within Data Space : 134.155.108.49:8890 associated with source dataset(s)

When is stored in a Vim variable/register/etc, it is stored as a NULL, and then translated back to a real newline under circumstances such as "put". Try inserting a newline in insert mode, i.e. ^V^J (or ^Q^J if you're using the mswin behavior). You will see a <00> show up. Now try these to help understand further: let @a = "a" . " " . "b" or let @a = "a" . "\x0a" . "b" and put it into the buffer using "ap or :put a You should see: a b "put" is especially smart about translating the newlines from NULLs back to 0x0a. Now do: call setline(".", @a) or call append("$", @a) You should see:

AttributesValues
rdfs:label
  • Newlines and nulls in Vim script
rdfs:comment
  • When is stored in a Vim variable/register/etc, it is stored as a NULL, and then translated back to a real newline under circumstances such as "put". Try inserting a newline in insert mode, i.e. ^V^J (or ^Q^J if you're using the mswin behavior). You will see a <00> show up. Now try these to help understand further: let @a = "a" . " " . "b" or let @a = "a" . "\x0a" . "b" and put it into the buffer using "ap or :put a You should see: a b "put" is especially smart about translating the newlines from NULLs back to 0x0a. Now do: call setline(".", @a) or call append("$", @a) You should see:
Version
  • 5(xsd:double)
dcterms:subject
dbkwik:vim/property/wikiPageUsesTemplate
Previous
  • 1265(xsd:integer)
Author
  • Eric Arnold
Complexity
  • intermediate
Created
  • 2006(xsd:integer)
ID
  • 1266(xsd:integer)
NEXT
  • 1267(xsd:integer)
Rating
  • 21(xsd:integer)
abstract
  • When is stored in a Vim variable/register/etc, it is stored as a NULL, and then translated back to a real newline under circumstances such as "put". Try inserting a newline in insert mode, i.e. ^V^J (or ^Q^J if you're using the mswin behavior). You will see a <00> show up. Now try these to help understand further: let @a = "a" . " " . "b" or let @a = "a" . "\x0a" . "b" and put it into the buffer using "ap or :put a You should see: a b "put" is especially smart about translating the newlines from NULLs back to 0x0a. Now do: call setline(".", @a) or call append("$", @a) You should see: a<00>b It's not a happy reality, since NULLs and newlines cannot cooexist in Vim script strings in various circumstances. In Vim 7 you have the option of giving a list to setline() and append(), which solves the line break ambiguity: call setline(".", [ 'a', 'b' ] ) I'm now using lists everywhere I can, in preference to concatenated strings with newline separators. I usually split() any such strings I find into a list for easier manipulation. This sidesteps all the usual pitfalls trying to handle line breaks manually as embedded characters.
Alternative Linked Data Views: ODE     Raw Data in: CXML | CSV | RDF ( N-Triples N3/Turtle JSON XML ) | OData ( Atom JSON ) | Microdata ( JSON HTML) | JSON-LD    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 07.20.3217, on Linux (x86_64-pc-linux-gnu), Standard Edition
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2012 OpenLink Software