In case of Sublime Text, the mouse actions are configured by what are known as mousemap files (that have a file extension of .sublime-mousemap
). You can have generally 2 variants of these files :-
Default.sublime-mousemap
: This will define mouse actions for any platform.Default ($platform).sublime-mousemap
: This will define mouse actions for a specific platform, where$platform
is any one ofWindows
,Linux
orOSX
depending on your operating system.
You can view the default shipped mousemap files by using View Package File
from the command palette and searching for mousemap.
In order to define your own mouse actions (or override any existing actions), you have to create a file by the name of Default.sublime-mousemap
in the User
directory (to get to this directory, select Preferences -> Browse Packages ...
from the main menu) for platform independent override (or Default ($platform).sublime-mousemap
for platform dependent overrides depending on your OS).
Once that's done, here is some basic knowledge about mousemap files (Note that there is no official or community documentation about mousemap files so everything is based on experimentation and what the dev's have said about such files).
Here are the meaning of some keys in mousemap files :-
-
button: This defines the name of the button. For example,
button1
refers to the left mouse button,button2
defines the right mouse button, the scroll wheel definesbutton3
. Similarly, you can havebutton4
.button5
etc. I am not sure how many such button names actually exist. Also for the scroll wheel, you havescroll_up
for upward scroll movement &scroll_down
for the opposite behavior. -
modifiers: This is a list of modifier keys like ctrl, alt etc. For example,
["alt"]
,["ctrl", "alt"]
. When you define a modifier list, all the modifier keys listed should be pressed simultaneously and then pressing/releasing the corresponding button triggers some action. -
command: This defines the command to be executed when the corresponding button is released after being pressed. If this command takes any arguments, you can have an args key for it.
-
press_command: This defines the command to be executed when the corresponding button is pressed. If this command takes any arguments, you can have a press_args key for it.
-
count: The number of times you have to press the corresponding button to trigger the action (by action, I mean execute the corresponding command/press_command)
NOTE: You can define both command and press_command if you wanted to.
Let's look at some examples :-
File name :- User/Default.sublime-mousemap
[
{
"button": "button2",
"modifiers": [],
"press_command": "echo",
"press_args": {
"message": "I am pressed"
},
"command": "echo",
"args": {
"message": "I am released"
},
}
]
Here, the right button (button2
) is bound to the built in echo
command. If you now right click, the default behavior would have been actually the opening of the context menu, but now we have overriden that behavior and now you can see the corresponding messages {'message': 'I am pressed'}
or {'message': 'I am released'}
in the console based on whether you have pressed or released after pressing.
For your case, you can have something like the following :-
[
{
"button": "button1",
"modifiers": ["alt", "ctrl", "shift"],
"press_command": "undo",
}
]
Now, when you now press button1
(while holding down alt, ctrl, shift simultaneously), the undo command should be executed. You can set modifiers to an empty list if you don't want that.
If you want to disable any button actions, just use the noop
command.
Example :-
[
{
"button": "button1",
"modifiers": [],
"press_command": "noop",
}
]
This will disable button1
and now you can't drag select anymore ;-) So be careful.
Note: This is a slightly modified version of my answer on this StackOverflow answer on mousemap files