Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sublime text bind mouse buttons to jump to cursor

Tags:

sublimetext

I want to bind my forward and back mouse buttons (4, 5) to jump between previous cursor positions. I have my file

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

My code is as such

[
  {
    "button": "button4",
    "command": "jump_back"
  },
  {
    "button": "button5",
    "command": "jump_forward"
  }
]

I have also tried

{
  "button": "button5",
  "modifiers" : [],
  "command": "jump_forward"
}

And even

{
  "button": "button5",
  "modifiers" : ["alt"],
  "command": "jump_forward"
}

But the default next / prev tab set-up is always used. Using the sublime default key bindings works however

"alt" + "-"
"shift" + "alt" + "-"
like image 292
myol Avatar asked Dec 02 '15 10:12

myol


2 Answers

Make sure you add these settings to a MOUSEMAP and not a KEYMAP.

If you open the folder of your key preferences and add create a file like this:

Default (Windows).sublime-mousemap

[
    {
        "button": "button4",
        "command": "jump_back"
    },
    {
        "button": "button5",
        "command": "jump_forward"
    }
]

Just make sure the filename conforms to whatever your keymap filename (e.g. replace WINDOWS with UNIX if that's how your keymap is named).

like image 105
Cactusman Avatar answered Nov 16 '22 04:11

Cactusman


For Linux:

Default (Linux).sublime-mousemap

{ "button": "button8", "command": "jump_back" },
{ "button": "button9", "command": "jump_forward" }

Default (OSX).sublime-mousemap

{ "button": "button4", "command": "jump_back" },
{ "button": "button5", "command": "jump_forward" }
like image 24
Tyler Avatar answered Nov 16 '22 03:11

Tyler