Sublime Forum

Some help with find_under_expand

#1

Hello everyone!

One of the most enticing features of SLT for me are the multiple cursors combined with the “find_under_expand” feature, but I’m continuously running into a little issue.

When selecting a token, SLT automatically highlights all other tokens. (I can’t add attachments, so I’ll try to show it with markup)

For example, when selecting “is”, SLT will highlight the 2nd “is”, but not the ‘is’ that is part of “This”. That means it highlights all ‘is’-tokens, not just all occurences of ‘is’

This [is] a sample text. It [is] meant to clarify what I mean.

However when I then use find_under_expand, it will select all occurences of ‘is’ it finds

Th[is] [is] a sample text. It [is] meant to clarify what I mean.

Is there a way to make find_under_expand behave like the token highlighting feature?
I would be ok with writing some Python, but not with completely duplicating the tokenizer of SLT :wink:

0 Likes

Multiple cursors for syntactic vs text matches
#2

This is by design:
If you have a selection (at least one char.) before running find_under_expand, the selection is used as-is.
If you have no selection (0 char. selection), the word under the cursor is selected and the search is whole word limited.

I think this behavior is very useful, always use CTRL+D when you want to select a word.
I don’t think there’s an option to change this behavior.
You can probably create a plugin to narrow the current selection before running find_under_expand two times and let it expand to the word again and search next occurence, but it could be tricky with multi-selection.

0 Likes

#3

Don’t get me wrong, I agree that this seems to be by design and I don’t presume the behaviour would be changed for me. Like I wrote, I’m just looking for a way to make SLT behave like this because well personally, I really only use this feature for refactoring (and there it really shines) and in this situation it’s usually not useful to mark partial words.

Using CMD+D without selection is sadly only semi-useful for me, although it does somewhat solve the issue. It does not really work with control-char tokens like “)”, “+” or “#” – so I would not have to use a different feature depending on what kind of tokens I want to select, but a different procedure. (select & CMD+D … vs. navigate-inside-word & CMD+D & CMD+D …). Also it’s quite annoying that find_under_expand case-sensitivity depends on the search settings…

I guess my brain works differently, but where would be the fun if we all would be the same :smile:

0 Likes