Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CTRL + Click Binding in Sublime Text 2

Tags:

sublimetext

One very long standing habit I have with my IDE of many years is that the CTRL (or command) + Click selects a full word. It is the equivalent of doing a double click on a word currently in ST2. I am hoping to be able to restore this ability in ST2. Would I go about it with a key-binding or a plugin?

like image 263
phirschybar Avatar asked Mar 14 '12 01:03

phirschybar


People also ask

How do I change key bindings in Sublime Text?

Users can customize their key bindings by creating a file named Default. sublime-keymap in their Packages/User/ directory. For example, the following will create a key binding to show unsaved changes, if any exist, via Ctrl+Shift+`.

Where is Sublime-keymap file?

Sublime Text comes with a default SUBLIME-KEYMAP file, which is located in the /​Packages/​Default directory, and a user SUBLIME-KEYMAP file, which is located in the /​Packages/​User directory.

How do I open a keymap file in sublime?

Key maps of the corresponding platform will be loaded in the Sublime Text editor. A user can open the keymap file or default key bindings using the option Preferences → Key Bindings.

How do you jump to a line in Sublime Text?

In Sublime Text, you can quickly jump to any line in the code. Hit Ctrl–G (Mac and Windows). Type in a line number and hit Return/Enter to go to that line.


2 Answers

If you create a sublime-text-2/Packages/User/Default (Linux).sublime-mousemap file (assuming you are on Linux) and put this in it (If the file is already there then put it at the end of the file within the square brackets already present):

[
    {
        "button": "button1", "count": 1, "modifiers": ["ctrl"],
        "press_command": "drag_select",
        "press_args": {"by": "words"}
    }
]

It will override the standard Ctrl+Click behaviour, and do what you want. However the default Ctrl+Click behaviour is very cool - allowing for simultaneous multiple selections and cursors (try Ctrl+Clicking in different places in a file), so you may want to reassign that functionality elsewhere. If you wanted to change the multi-select feature to Ctrl+Alt+click, you can do this by also adding, inside the square brackets:

{
    "button": "button1", "count": 1, "modifiers": ["ctrl", "alt"],
    "press_command": "drag_select",
    "press_args": {"additive": true}
}
like image 61
fraxel Avatar answered Oct 26 '22 08:10

fraxel


It Works for st3, i think works in st2

Linux - create "Default (Linux).sublime-mousemap" in ~/.config/sublime-text-3/Packages/User

Mac - create "Default (OSX).sublime-mousemap" in ~/Library/Application Support/Sublime Text 3/Packages/User

Win - create "Default (Windows).sublime-mousemap" in %appdata%\Sublime Text 3\Packages\User

[
    {
        "button": "button1", 
        "count": 1, 
        "modifiers": ["ctrl"],
        "press_command": "drag_select",
        "command": "goto_definition"
    }
]
like image 35
Jirson Tavera Avatar answered Oct 26 '22 07:10

Jirson Tavera