Sunday, March 5, 2017

Ambiguity about what $ means?

Hi,

I am trying to match midway through a line and then continue to the rest of the file but it seems I am not allowed.

so say I have

=====
1.
2. mary
3.
4. had a little lamb
=====

I am on line 2, right at the beginning

Let's say I do:

s/$/XXX/

I get

=====
1.
2. maryXXX
3.
4. had a little lamb
=====

which you would expect. 'match end-of-line and starting there substitute with XXX'

now let's start from the beginning:

=====
1.
2. mary
3.
4.had a little lamb
=====

I want to do a similar thing but match now just the end-of-line itself but also everything that comes after:

s/$\_.*/XXX/

apparently should match 'end-of-line, then using \_. any char including enf-of-line as many times as necessary to the end of the file. Then replace with XXX

instead this happens:
'E486: Pattern $\_.* not found' ?!?

does $ not mean what I think it means?
because oddly when I wrote:

s/\n\_.*/XXX/

it exactly gives:

=====
1.
2. maryXXX
=====

which you would expect.

so seems like $ doesn't really mean end-of-line in certain cases. I am a bit unclear about this. Can anybody explain strange behaviour?

Thanks in advance!!
Pablo.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment