Sunday, July 3, 2011

Re: How can I disable search highlighting after I use search for delete {motion}?

Xiaopan Zhang <zhangxiaopan@gmail.com> [11-07-03 09:08]:
> Hi there,
>
> This is a bit complicated, let me try to explain myself a bit.
>
> First of all, search highlighting is a very useful feature and I
> always turn it on.
>
> Then, in some situations, I need complicated movement to delete some
> text other than simple motions such as 'w' or '%', etc., for example,
> for the following text:
>
> new_variable = old_badname_variable + some_other_variable + 7
>
> and my cursor is at the underscore just before 'badname', and I want
> to delete some text to make the line read
>
> new_variable = old_variable + 7
>
> I can use the following key strokes 'd/_variable + 7<CR>', will does
> the job precisely, However, one problem is that after the deletion,
> '_variable + 7' will be highlighted if it occurs in other places in
> the same file, which is undesirable.
>
> Does anybody have solution to this annoying problem?
>
> --
> 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
>

Hi,

I have "another" solution for that problem: Do not search!
(No I am not kidding ... :) 8) ;)

The string is:
new_variable = old_badname_variable + some_other_variable + 7

The cursor is at the beginning of "_badname" (over _)
or at "badname" (over b)

Without entering the commandline with ':' type
ct<space>
for <space> type a space not the characters of '<space>'
then enter your repacement string
hit escape

If this does not work for you you can insert the following
mapping into your $HOME/.vimrc:

map <f5> :nohlsearch<CR>

then, after the deletion, simply hit <F5> and the highlightning
is gone until you do the next search.

HTH!

Have a nice weekend!
Best regards,
mcc

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

No comments:

Post a Comment