CTRL + Click Binding in Sublime Text 2

2019-03-09 14:56发布

问题:

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?

回答1:

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}
}


回答2:

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"
    }
]


标签: sublimetext