Sunday, February 5, 2017

Re: Sed substitution did not go as planned...

Hi Tim, and all,

On Sun, 5 Feb 2017 13:09:29 -0600
Tim Chase <vim@tim.thechases.com> wrote:

> On 2017-02-04 05:14, Marcus Martinez wrote:
> > ...and modified the first ten lines using Sed substitution...
> > :1,10 s/^/--/
> >
> > After running this command the beginning of lines 1 through 10 do
> > have the "--" correctly placed. However, the first character of
> > each line in the file is now highlighted (as shown in the attached
> > image). The pattern now recurs for any text file I open with vim.
> >
> > Why does this happen? How can I "undo" this new pattern so that vim
> > does not highlight the first character of each line?
>
> Why? You have 'hls' set, so it highlights the last thing you
> searched for. In this case, /^/ which is the beginning of the line.
>
> How can you undo it? A couple different ways:
>
> - if you like the search highlighting but just want to hide it for
> these search results, use ":noh" to turn it off until the next time
> you do a search
>
> - alternatively, you can search for junk that isn't in your file:
>
> /lkasjdfdlkjgadslkgjads
>

One can also nullify the search-pattern register:

:let @/=''

That way, vim will not highlight anything.

Regards,

Shlomi Fish

--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
List of Portability Libraries - http://shlom.in/port-libs

Chuck Norris once solved 100 million deals of Freecell in a minute. By hand.
http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
--
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