Sublime Forum

How to get the status of case_sensitive and whole_word in Find panel?

#1

00%20AM

In the Find panel, there are several icons to tell whether case_sensitive and whole_word are on or off during the finding process.

These statuses are important, because they also have an impact on the find_under_expand and other commands.

I know that there are commands such as toggle_case_sensitive and toggle_whole_word that may toggle these statuses.

But is there any way, in plugin development, to get the status of case_sensitive and whole_word in the Find panel?

0 Likes

#2

It is possible I believe to get the state of the Regular Expression option since the find input widget uses a different syntax for it (source.regexp instead of text.plain) (as long as the input focus is in the find widget) but for others, I don’t think as of today there is a way to get their states. There is an open issue on the issue tracker about this.

0 Likes

#3

Thank you @UltraInstinct05 for the answer and the link!

Then this sounds disappointing, because it is really inconvenient, not just for plugin development, but also for a normal user.

I believe many users like me constantly need to alternate between on and off for the whole word mode when doing find_under_expand. Currently I could only pop up the Find panel, take a look at the button to see whether whole word mode is on or off, then do the find_under_expand. (Or by trial and error.)

If this status could be retrieved somewhere, then it would be very easy for me to write a few lines of Python code to display the whole word mode at the status bar.

0 Likes

#4

You can always give a thumb’s up to the issue and additionally describe of what use you would put if such a functionality were to be implemented so that it would help the dev’s prioritize it better for future releases.

0 Likes

#5

OK. Now I solved the problem myself, in a different but complete approach – I wrote a plugin.

This plugin implements Quick Find / Quick Add subject to case-sensitive / whole-word restrictions with the current flag status always displayed on the status bar.

It’s called Exact Quick Find and is available now on Package Control here.

At the basic level, you do anything that the built-in Quick Find / Quick Add can do, while respecting the case-sensitive / whole-word / wrap-scan restrictions.

At the advanced level, it provides a full set of peek-based navigation and selection methods to boost productivity.

Here is a screencast demonstrating the exact search for the whole word "debug" in lowercase.

Note that the find flags on the status bar are toggled from [c][w][R] to [C][W][R] . [C] for case sensitive. [W] for whole word. [R] for wrap scan.

Also note that, with the whole-word flag on, the search skips all the non-whole-word cases such as "_debug_print" and "debug_level".

You can always view the flags and use key bindings to easily toggle them.

0 Likes