Loading ...
Sorry, an error occurred while loading the content.
 

Re: ^@ in my strings?

Expand Messages
  • Benji Fisher
    ... Short answer: or n . :help NL-used-for-Nul Long answer: it might be easier not to yank the selection into a string, depending on what you
    Message 1 of 3 , Aug 30, 2002
      David Fishburn wrote:
      >
      > Vim 6.1.165 W2K
      >
      > I have the following in my buffer:
      > pid INT NOT NULL,
      > cid INT NOT NULL,
      > ctext decimal(5,2) NULL,
      >
      > I visually select these rows and then echo it:
      > newly yanked: pid INT NOT NULL,^@ cid
      > INT NOT NULL,^@ ctext decimal(5,2) NULL,
      >
      > I want to write a substitution string that returns this:
      > pid, cid, ctext
      >
      > But I didn't realize that substitite would treat these as all one
      > string.
      >
      > I was going to do this:
      > substitute( columns, '^[ \t]*\([a-zA-Z0-9_]*\).*', '\1,', "ei" )
      >
      > This would have given me this:
      > pid,
      > cid,
      > ctext,
      >
      > I am not sure how to reference ^@.
      > Ctrl-v ctrl-M gives me ^M.
      > How do I get ^@?

      Short answer: "\<C-J>" or "\n". :help NL-used-for-Nul

      Long answer: it might be easier not to yank the selection into a string,
      depending on what you want to do with it. Once the lines are selected, just do

      :s/^\s*\(\k\+\).*/\1,

      Note that I use '\s' instead of '[ \t]' and '\k' instead of '[a-zA-Z0-9_]'
      (maybe a little different, maybe exactly the same). Finally, AFAIK the only
      flag that substitute() understands is "g"; I think it ignores your "ei".

      HTH --Benji Fisher
    Your message has been successfully submitted and would be delivered to recipients shortly.