Re: match() linebreak
- On Sun, 2 Mar 2003, Antoine J. Mechelynck wrote:
> Well, there are questions concerning ^J (newline, used by vim toI tried ^V^J and ^V^V^V^J with single and double quotes. None of them
> 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.
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 onesThis did it. Thanks!
> <Char-10>Interesting. I didn't know yet that char's can be denoted this way, too.
> <EOL> will match (at some places) an end-of-line
> or else, you might try a circuitous approach:char2nr() told me "char. 10", it's just, I didn't know what symbol to
> 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.
use to denote it...
Thanks a lot, Antoine!
- Klaus Bosau wrote:
> On Sun, 2 Mar 2003, Antoine J. Mechelynck wrote:Did you try using "\<C-J>" instead of '^@' ?
>>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?
HTH --Benji Fisher
- On Sun, 2 Mar 2003, Benji Fisher wrote:
> Klaus Bosau wrote:I tried it now and it looked not as bad. (I'm wondering a bit why this
> > Is there a chance to use ^@ (<C-V><C-J>) this way, too?
> Did you try using "\<C-J>" instead of '^@' ?
does not need an additional "execute" here, like in normal mode
> :help expr-stringI'll take a look...