unblevable / quick-scope

Lightning fast left-right movement in Vim
MIT License
1.43k stars 54 forks source link

Add option to only highlight characters after pressing f,F,t,T. #2

Closed viccuad closed 9 years ago

viccuad commented 9 years ago

Right now the highlighting happens all the time on the cursor line. As it can be a bit distracting, it could be nice to add an option to only display the characters' highlighting after pressing f, F, t or T.

MarcusSky commented 9 years ago

Yeah, I would love to see such option, too!

nt0xa commented 9 years ago

+1 for such option

vappolinario commented 9 years ago

Having this setting would be great.

VanLaser commented 9 years ago

... and keep (or re-enable) the highlight when ; or , is pressed, + disable it when any other keys are pressed.

cvlmtg commented 9 years ago

why not trying any other plugin like vim-sneak, easymotion, clever-f etc? there are a lot of different plugins that tries to improve on vim motions in slightly different ways, so maybe there's already one that is closer to you needs.

vyp commented 9 years ago

@cvlmtg Those plugins are great, but, correct me if I am wrong, they do not do what this feature request wants, so it's not like you can just use one of those plugins intead of quick-scope.

Or if you're saying quick-scope in its current state is obsolete because of those plugins, I would not agree. From the readme:

  • This plugin neither introduces new motions nor overrides built-in ones.
    • You don't have to learn any new commands or mappings.
    • This helps you to become a better user of vanilla Vim.

The advantage is it's quite lightweight and much easier to get started with than the plugins you mentioned. Everyone already knows how to use fFtT;,, quick-scope simply makes it even more efficient, without actually changing the functionality of it (I think). Yes perhaps those plugins are a step up, but I think you should be able to see why some would prefer something less 'intrusive' like this.


With regards to the OP, I am +1. I might not use this feature myself (not sure), but I can see why it can be a useful option to have.

davidmh commented 9 years ago

In the meantime, you could turn off the highlight by default, with:

let g:qs_enable = 0

And mapping QuickScopeToggle as recommended on the documentation.

cvlmtg commented 9 years ago

@vyp no I'm not saying this plugin is obsolete, I like the idea behind this plugin. I was just suggesting to all the people requiring this option to try the other plugins, as they might fit better their needs or at least come closer to their needs. I'm pretty sure there are at least a couple that highlight the possible targets when you press a key. however there are a lot of them and I haven't tried them all. and the point of my previous message is that perhaps even the people requiring this option haven't tried them all.

szaghi commented 9 years ago

:+1:

cszentkiralyi commented 9 years ago

I really like this idea, and including it in the plugin would be ideal. In the mean time, I have implemented this in my own .vimrc; if anyone else wants a hacked-together solution, you can find the relevant bits here: https://gist.github.com/cszentkiralyi/dc61ee28ab81d23a67aa

drzel commented 9 years ago

Came here to request this exact feature. @cszentkiralyi thanks for the hack.

gabesoft commented 9 years ago

+1

benoittgt commented 9 years ago

Thanks @VanLaser and @cszentkiralyi it's perfect.

VanLaser commented 9 years ago

I'd like to suggest a small modification to the plugin, which would help with the selective highlighting: there could be an additional global variable, e.g. g:quickscope_direction or similar, that could take these values: 1 (= highlight after cursor position), 2 (highlight before cursor position) and 3 (highlight entire line), with the default value 3. This variable would be checked by s:highlight_line() in order to conditionally highlight before, after or the entire line (it would be very easy, considering how the function is written).

This would help when using selective highlight functionality (e.g. for @cszentkiralyi's solution) in the following way: maps for f or t would enable QuickScope, and briefly set g:quickscope_direction to 1; maps for F or T would enable QuickScope and set g:quickscope_direction to 2; both would disable QuickScope afterwards, if needed, but - in any case - they would set g:quickscope_direction back to 3, so that default functionality is not changed.

If you have nothing against the idea, but don't feel like writing it, I could probably do it and propose a pull request.

vyp commented 9 years ago

fwiw, I think that's a great idea @VanLaser. +1

unblevable commented 9 years ago

Hey everyone, so I'm finally working on this feature now after seeing the overwhelming number of users who want it added.

In response to @cvlmtg and @vyp, quick-scope originally didn't have this feature because I felt its greatest advantage was that it was always "on" so that you could calculate your movements beforehand. Also, I thought that having quick-scope trigger on a key would make it an inferior option to other motion-plugins since a few of them could at least guarantee you could move to any word on a line in the same number of keystrokes.

However, after all the feedback, I feel that quick-scope still has its advantages even with the proposed option on.

Much thanks to @cszentkiralyi and @VanLaser for creating the hack to make everyone happy while I was gone. Unfortunately, I don't think I can simply add your code to the repo without major modifications, but I still would like to mark you as contributors somehow. You can see why after looking at the task list:

Let's call the option g:qs_highlight_on_key_press:

Any thoughts?

vyp commented 9 years ago

quick-scope originally didn't have this feature because I felt its greatest advantage was that it was always "on" so that you could calculate your movements beforehand

I actually agree with this too. When it's always on, I don't have to 'wait', even if only for a half a second, for my fingers to pick up what key to press next. But at the same time, I can see why some would like some sort of option that does not always keep it on, because it can be distracting. I try to make it less distracting by change it to a lower contrast colour though.

VanLaser commented 9 years ago

This is very good news :) Meanwhile, two things:

Fingers crossed :)

unblevable commented 9 years ago

If anyone can test out the pull request, I'd appreciate it!

VanLaser commented 9 years ago

So far, so good! I use 'vim-plug', the relevant line to test would be:

Plug 'unblevable/quick-scope', { 'branch': 'highlight-on-key-press' }
stsievert commented 9 years ago

+1. I find the underline mildly annoying and would appreciate this feature!

drzel commented 9 years ago

Also testing the highlight-on-key-press branch. No issues so far.

unblevable commented 9 years ago

I think the pull request is good to go now. I'll merge it in later today.