f



[vim] pattern highlight when using g

Hi there,

I'm fairly new to vim and I'm exploring plugins, stealing vimrcs and listening
to vimcasts/screencasts. But now I think I'm narrowing down my requirements to
thing that are more and more specific.

I've recently found the 'power of g' (http://vim.wikia.com/wiki/Power_of_g) and
it is an amazing feature. The only drawback I found is that the pattern it is
not been highlighted as with the search. I have 'set incsearch' in order to
verify live if my regex are correct, but with the g command I'm practically
blind!

Is there a way to activate the pattern highlight while using g?

Any pointer/suggestion/comment is appreciated,

Al

-- 
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on Usenet and in e-mail?
0
al
11/27/2016 12:01:33 AM
comp.editors 4871 articles. 0 followers. Post Follow

5 Replies
208 Views

Similar Articles

[PageSpeed] 35

On 27 Nov 2016 00:01:33 GMT, al.basili@gmail.com wrote:
> Is there a way to activate the pattern highlight while using g?
 
:set hlsearch


-- 
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
                                       http://BrownMath.com/
                                  http://OakRoadSystems.com/
Shikata ga nai...
0
Stan
11/27/2016 9:15:46 AM
Stan Brown <the_stan_brown@fastmail.fm> wrote:
> On 27 Nov 2016 00:01:33 GMT, al.basili@gmail.com wrote:
>> Is there a way to activate the pattern highlight while using g?
>  
> :set hlsearch

I have the incsearch plugin installed and I think there might be some conflict
going on. I actually use it such that nohl is set on a move after a search has
been completed. What I would tipically do is hit "/" and then insert a pattern
and with incsearch set it will automatically show the found pattern. At that
point I hit <CR> and the pattern is highlighted over screen, but when I then
move (word or line moves), the plugin would set nohl automatically so that I do
not see all that highlighted text aroind.

Now if I do 'set hlsearch' as suggested, does not highlight my pattern when I
use ':g'.

Any ideas?

Al

-- 
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
0
al
11/27/2016 3:06:21 PM
On 27 Nov 2016 15:06:21 GMT, alb wrote:
> 
> Stan Brown <the_stan_brown@fastmail.fm> wrote:
> > On 27 Nov 2016 00:01:33 GMT, al.basili@gmail.com wrote:
> >> Is there a way to activate the pattern highlight while using g?
> >  
> > :set hlsearch
> 
> I have the incsearch plugin installed and I think there might be some conflict
> 
> Any ideas?

I don't know the incsearch plugin, but try removing it. If that fixes 
hlsearch, then you have to decide which one you want more, or else 
map hlsearch to a key and tap it after every search.(*) If hlsearch 
without incsearch still doesn't work as it should, then I'm afraid I 
don't have any advice.

(*) And of course you should report the problem to the maker of the 
plugin.

-- 
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
                                       http://BrownMath.com/
                                  http://OakRoadSystems.com/
Shikata ga nai...
0
Stan
11/27/2016 4:23:31 PM
Stan Brown <the_stan_brown@fastmail.fm> wrote:
> On 27 Nov 2016 15:06:21 GMT, alb wrote:
>> 
>> Stan Brown <the_stan_brown@fastmail.fm> wrote:
>> I have the incsearch plugin installed and I think there might be some conflict
>> 
>> Any ideas?
> 
> I don't know the incsearch plugin, but try removing it. If that fixes 
> hlsearch, then you have to decide which one you want more, or else 
> map hlsearch to a key and tap it after every search.(*) If hlsearch 
> without incsearch still doesn't work as it should, then I'm afraid I 
> don't have any advice.

I've just tried it out, unfortunately disabling the plugin does not remove the
problem. Even with 'hlsearch' and 'incsearch' set, when I'm using the :g command
I don't have any highlighting going on as I would during a normal search.

The :g command is very useful when wanting to act on multiple lines, but if the
pattern is not highlighted while typing it would be very difficult to use. One
way around the issue would be to perform a normal search, which will highlight
the matching pattern as I type them and then do :g//<command> which will use the
latest search pattern. But this flow is somewhat cumbersome...

Any idea is appreciated,

Al
0
al
11/27/2016 5:03:36 PM
On 27 Nov 2016 17:03:36 GMT, alb wrote:
> The :g command is very useful when wanting to act on multiple lines, but if the
> pattern is not highlighted while typing

It's not supposed to be. And that's the same as when you type a / 
command. The difference is that with a / command its whole purpose is 
to move you to the next matching location, so the spot you're moving 
to gets highlighted (in reverse video, on my PC) while you're typing 
the regular expression. But other occurrences in the visible window 
are not highlighted in that way while you're typing the regex, 
whether hlsearch is on or off.

hlsearch kicks in as soon as the search or g command is complete. The 
all occurrences of the searched-for regex are highlighted, with a 
yellow background (on my PC).

You can always type :g/regex/ and then `` to return to your previous 
position. Press : then up arrow and either correct your :g command or 
finish it.

-- 
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
                                       http://BrownMath.com/
                                  http://OakRoadSystems.com/
Shikata ga nai...
0
Stan
11/27/2016 8:39:12 PM
Reply: