Sublime Forum

[BUG] CMD-D Repeat not working [OS X 2215]

#1

Hi,
if have removed the “$” from my “word_separators” setting for PHP programming.

CMD-D now also selects the “$” when used on variables. However, pressing CMD-D again does not select the next instance of that variable anymore. If I select that variable via mouse, CMD-D (repeat) works as expected.

Regards, Thorsten.

1 Like

Build 3007
[solved] Double Click PHP Varible won't highlight $
#2

I tried to find a workaround for this Problem (still present in ST3 and also documented here by somebody else http://sublimetext.userecho.com/topic/61252-find-whole-word-for-variables/). I came up with the following key-binding:

{ "keys": "super+d"], "command": "expand_selection", "args": {"to": "scope"}, "context":
        
            { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
            { "key": "preceding_text", "operator": "regex_contains", "operand": "\\$", "match_all": true },
            { "key": "selector", "operator": "equal", "operand": "source.php" }
        ]
}

It works quite well for me. The regex could be optimized by only check for $ at the beginning of the current word, but I don’t know if that is possible.

Greetings!

0 Likes

#3

[quote=“planet”]I tried to find a workaround for this Problem (still present in ST3 and also documented here by somebody else http://sublimetext.userecho.com/topic/61252-find-whole-word-for-variables/). I came up with the following key-binding:

{ "keys": "super+d"], "command": "expand_selection", "args": {"to": "scope"}, "context":
        
            { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
            { "key": "preceding_text", "operator": "regex_contains", "operand": "\\$", "match_all": true },
            { "key": "selector", "operator": "equal", "operand": "source.php" }
        ]
}

It works quite well for me. The regex could be optimized by only check for $ at the beginning of the current word, but I don’t know if that is possible.

Greetings![/quote]

Thank you for this workaround!

0 Likes

#4

[quote=“planet”]I tried to find a workaround for this Problem (still present in ST3 and also documented here by somebody else http://sublimetext.userecho.com/topic/61252-find-whole-word-for-variables/). I came up with the following key-binding:

{ "keys": "super+d"], "command": "expand_selection", "args": {"to": "scope"}, "context":
        
            { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
            { "key": "preceding_text", "operator": "regex_contains", "operand": "\\$", "match_all": true },
            { "key": "selector", "operator": "equal", "operand": "source.php" }
        ]
}

It works quite well for me. The regex could be optimized by only check for $ at the beginning of the current word, but I don’t know if that is possible.

Greetings![/quote]

Thank you! This could be optimized at least by adding the “following_text” key, in this form it gave me multiple false selections:

{ "keys": "super+d"], "command": "expand_selection", "args": {"to": "scope"}, "context": { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, { "key": "preceding_text", "operator": "regex_contains", "operand": "\\$", "match_all": true }, { "key": "following_text", "operator": "regex_contains", "operand": "\\s", "match_all": true }, { "key": "selector", "operator": "equal", "operand": "source.php, source.scss" } ] },

0 Likes

#5

Hi. Please tell how to make it work for javascript files?

0 Likes

#6

Seems to work only when cursor is inside variable, and doesnt highlight other occurances immediately(
May be someone has a modified solution for this bug.

0 Likes

#7

there is a suggestion there to try the WordHighlight package

0 Likes

#8

Thanks. WordHighlight highlights good, but it can select only NEXT word.

{ “keys”: [“ctrl+enter”], “command”: “select_highlighted_next_word”, “context”:
[ { “key”: “selection_empty”, “operator”: “equal”, “operand”: false },
{ “key”: “setting.is_widget”, “operator”: “equal”, “operand”: false }
]
}

May be someone know how to make it behave like default ctrl+d?

0 Likes