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

Re: match() linebreak

Expand Messages
  • Klaus Bosau
    ... I tried ^V^J and ^V^V^V^J with single and double quotes. None of them worked, except ^V^J when source d from a register. Source ing it from a file failed.
    Message 1 of 7 , Mar 2, 2003
    • 0 Attachment
      On Sun, 2 Mar 2003, Antoine J. Mechelynck wrote:

      > Well, there are questions concerning ^J (newline, used by vim to
      > represent a null internally) and ^@ (null, used by vim internally to
      > terminate a string or a line). If you place one or more ^@ inside
      > a string, the string will end on the character preceding the first
      > one. So we're back to square one. In a script, there are several
      > things that can be used as some places, and not at others, to
      > represent a ^J
      >
      > ^J entered as ^V followed by ^J When text is
      > re-interpreted several times, you may need to "protect" it by a Ctrl-V
      > (entered as ^V followed by ^V) or even three of them.

      I tried ^V^J and ^V^V^V^J with single and double quotes. None of them
      worked, except ^V^J when source'd from a register. Source'ing it from
      a file failed. Similar error.

      > \n inside double quotes, not single ones

      This did it. Thanks!

      > <Char-10>
      > <Char-012>
      > <Char-0x0A>
      > <EOL> will match (at some places) an end-of-line

      Interesting. I didn't know yet that char's can be denoted this way, too.

      > or else, you might try a circuitous approach:
      >
      > Do a yy (yank line) to (for instance) register a on an empty line.
      > This will save the ^J into the register. To include it at some point
      > in a string, use the expression:
      > "the first part of the string" . @a . "the end of the string"
      > which can, if needed, be saved into a variable, or another register
      > (e.g., "b) by using :let @b = "the first part of the string" . @a
      > . "the end of the string".
      >
      > Some experimenting may be needed.

      char2nr() told me "char. 10", it's just, I didn't know what symbol to
      use to denote it...

      Thanks a lot, Antoine!

      Klaus
    • Benji Fisher
      ... Did you try using instead of ^@ ? ... HTH --Benji Fisher
      Message 2 of 7 , Mar 2, 2003
      • 0 Attachment
        Klaus Bosau wrote:
        > On Sun, 2 Mar 2003, Antoine J. Mechelynck wrote:
        >
        >
        >>IIRC, the output of :registers shows newlines as ^J -- Have you try
        >>matching for that? (Enter it by pressing Ctrl-V followed by Ctrl-J;
        >>and replace the Ctrl-V by a Ctrl-Q if your configuration of vim uses
        >>Ctrl-V to paste from the clipboard.)
        >>
        >>I may be wrong, but I thing it would match either a null or a newline.
        >
        >
        > Hi Antoine,
        >
        > thanks! It worked as you said when typed in by hand. Using it within
        > a script however (I tried
        >
        > if match(@", '^@') > -1 | echo 'found' | endif
        >
        > ) returned
        >
        > E115: missing quote...
        > E15: Invalid expression: match(...
        >
        > Is there a chance to use ^@ (<C-V><C-J>) this way, too?

        Did you try using "\<C-J>" instead of '^@' ?

        :help expr-string

        HTH --Benji Fisher
      • Klaus Bosau
        ... I tried it now and it looked not as bad. (I m wondering a bit why this does not need an additional execute here, like in normal mode commands...) ...
        Message 3 of 7 , Mar 4, 2003
        • 0 Attachment
          On Sun, 2 Mar 2003, Benji Fisher wrote:
          > Klaus Bosau wrote:
          >
          > > Is there a chance to use ^@ (<C-V><C-J>) this way, too?
          >
          > Did you try using "\<C-J>" instead of '^@' ?

          I tried it now and it looked not as bad. (I'm wondering a bit why this
          does not need an additional "execute" here, like in normal mode
          commands...)

          > :help expr-string

          I'll take a look...

          Thanks!

          KLaus
        Your message has been successfully submitted and would be delivered to recipients shortly.