Sublime Forum

[SOLVED] Highlighting variables including the dollar symbol?

#1

Hi

Is there a way to specify the rules for highlighting words and variables using - for example - Ctrl+D or double clicking a word?

What I mean is, if you have a variable like $example, double clicking this would highlight everything including its dollar symbol so you can copy/paste it without having to first type an additional dollar symbol.

The current behaviour is, if you double click $example, only “example” is highlighted and the dollar symbol is not.

Also, in the same vein, can you specify “smart highlighting” or “smart caret positioning” so that if you have a variable with underscores or camelCase, double clicking only highlights a certain part of the variable? For example: $example_with_underscores or $exampleWithCamelCase would only highlight “with” if I double-clicked on “with”? Then if I double clicked again, it would proceed to select the entire variable?

Thanks

0 Likes

#2

For the first part of the question, you’d have to adjust the word_separators setting to not include $ sign. However, if you aim for a more-or-less consistent php support, you will currently not get one. E.g. “find” + “whole word” does not take word_separators into account, which gets in the way of replacing variables, and does not help one single bit (see userecho entry, and please vote if it applies to you).

The second part is tricker, there is probably no way to do what you want without writing a plugin to expand selection accordingly.

1 Like

#3

Brilliant. This worked. Adding “_” to that list also allows separate highlighting of underscored terms in variables, but as you said, modifications would be needed to get it to “expand selection” as I wanted. Thanks!

0 Likes