-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Search (not) in comments/string literals #6546
Comments
This is basically a duplicate of #6530, except replacing the scope selector with checkboxes for string literals and comments instead of a freeform scope selector. Perhaps as a scope selector is way more powerful, just a drop-down for some suggested selectors with friendly names would be suitable. And those could perhaps be read from some configuration file. |
Duplicate of #6530, which suggests to provide an input panel for user configurable selectors such as |
It is true that a scope selector is more powerful, and I had seen #6530. I support that one too, however I imagine it is way less user friendly than what I proposed, since I imagined there will be tens if not hundreds of scopes to select from. My idea was too be able to search (and replace) very easily in code or human text only, since that is a clear distinction that often is made. |
Buttons need styling and support by themes with adding value for two special use cases only. Being able to add selectors or predefined aliases for them to the "Where:" field or possibly a new one is way more flexible. User could be assisted by completions or pre-defined aliases for a set of common selectors. Something like the |
Problem description
Often we (do not) want to search for code that has not been "commented out", i.e. variable names that also happen to be a word that often occurs in comments or strings. It would enhance productivity a lot if we could search/search and replace in all string literals/non string literals only/comments/non-comments only.
Preferred solution
Two new tri-state buttons/checkboxes left to the find/replace input box. One that lets you search within string literals/outside of string literals/both, and one that lets you search within comments, outside of comments, or both.
Alternatives
Since above solution may clutter the search screen, an alternative could be made where the "within selection" button is replaced by a dropdown: search all/search in selection only/search in code only/search outside of code only/search in string literals only/search in comments only. There may be more options based on color scopes.
Additional Information
Now I realise this easier said than done considering all the languages that Sublime Text supports. But since comments are recognised in the color schemes and it has a color scope and there is a very limited plugin (https://gist.github.com/gwenzek/a16d40ba36268ac84716) that uses exactly that feature, it should be possible to implement. (The quoted plugin, however, is not as useful, since it is buggy and cannot search multiple files, which is exactly where you would need this feature the most.)
Searching in string literals can be tougher and may not be possible, especially since many languages like PHP have ways to add code to strings ( "Hello, $name!" ) which complicate things a lot, but most of the time, the color scopes have solutions for this too.
A configuration file may be needed per supported language to define search scopes on the basis of colouring scopes.
The text was updated successfully, but these errors were encountered: