huoguangjin / MultiHighlight

Jetbrains IDE plugin: highlight identifiers with custom colors 🎨💡
https://plugins.jetbrains.com/plugin/9511-multihighlight
GNU General Public License v3.0
103 stars 22 forks source link

Can't propagate highlight selections to multiple files. #34

Open bedge opened 1 year ago

bedge commented 1 year ago

Often one wants to see where a set of variables are used, and this may span multiple files. If one highlights these in one file, they are not also highlighted in other open files where they occur.

While, true, one can also select and highlight the same strings in the other files, this is time consuming, and they also default to different colors. This detracts from the usefulness of the plugin.

The vim https://vim.fandom.com/wiki/Highlight_multiple_words plugin works this way and is super-useful. I still resort to using vim just for this feature, as there is nothing equivalent any of the jetbrains tools.

image

Even if automatically highlighting in every file is not possible, it would be useful to be able to save the highlight selections from one file and load in another. eg: Save the list of highlighted words and their current colors, and load in other files to get matching highlights.

huoguangjin commented 1 year ago

I see.

The Vim plugin you mentioned is based on text matching for highlighting, while MultiHighlight is based on syntax tree element (PSI).

Initially, MultiHighlight only highlight identifiers in a single editor, and later added the feature of synchronizing highlights in different editors of the same file. MultiHighlight does not highlight one same identifier in different editors corresponding to different files. This has the advantage of searching within only one file, which makes searching faster.

huoguangjin commented 1 year ago

If MultiHighlight supports cross-file highlighting, there are several issues to consider:

All of the above points will bring certain performance costs.

bedge commented 1 year ago

This has the advantage of searching within only one file, which makes searching faster.

I don't doubt that. It would be a performance hit, however, it would help with multi-file comprehension to see places that the same label is present. In code with a lot of global context, eg: bash, as well as OO, where objects with common methods are accessible from multiple files, it's super helpful to be able to see all uses of obj.function-X() in all open windows. This works well with the Intellij multi-file search. What would be fantastic is to integrate with the IntelliJ search as well. Even better would be to retain the colorization for some number of recently searched items.

bedge commented 1 year ago

Another thought on this - The syntax tree vs plaint text match explains why there are cases where this plugin doesn't highlight all instances of a string. Is it feasible is to use this plugin source as a basis for a new variant that is a text matcher? Granted, it's a different product that fills a different need but I think there's a need for both.