Sublime Forum

Double click equivalent by key press?

#1

When double clicking, it selects the current word and also highlights other occurrences of the word in the file.

I’m trying to create a key that does this.

The default behaviour of ctrl+shift+space is similar:

{ "keys": ["ctrl+shift+space"], "command": "expand_selection", "args": {"to": "scope"} },

This does the selection (but includes a few characters that double click doesn’t, but also doesn’t highlight other occurrences.

Double click is defined in the mousemap:

{
		"button": "button1", "count": 2,
		"press_command": "drag_select",
		"press_args": {"by": "words"}
	},

But, If I add this to as a key in the keymap file:

{ "keys": ["ctrl+shift+space"], "command": "drag_select", "press_args": {"by": "words"} }

or

{ "keys": ["ctrl+shift+space"], "command": "drag_select", "args": {"by": "words"} }

or

{ "keys": ["ctrl+shift+space"], "command": "drag_select", "args": {"to": "words"} }

I also tried

{ "keys": ["ctrl+shift+space"], "command": "expand_selection", "args": {"to": "words"} },

None of these have any affect when pressed. How can I trigger the equivalent of double clicking at the cursor position via a key press?

0 Likes

#2

Simplistically, ctrl+d (or cmd+d if you’re on MacOS) will do what you want; it selects the word that the cursor is inside of directly.

1 Like