Sunday, February 5, 2017

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

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

- if the highlighting annoys you all the time, you use

:set nohls

to turn it off completely.


I generally fly with 'nohls' set and only turn it on when I actually
want that functionality. I also remap control+L (usually just a
simple :redraw of the screen) to also do a :noh in the process:

:nnoremap <c-L> :noh<cr><c-L>

which feels intuitive to me. YMMV.

You can read more at

:help 'hls'
:help :noh

-tim





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