Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add mouse click `goto definition` in sublime text 3.
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"
}
]
@phackwer

This comment has been minimized.

phackwer commented Feb 11, 2015

Thx. I made a full how-to make sublime more like eclipse. It's in portuguese, but I think you can easily get what is important there, since they are all package list or config files. The packages are most for PHP development, so, ignore them since you problably work with other languages.

https://gist.github.com/phackwer/2bd92058a7dc8d68a35f

Hope you enjoy.

@sagivo

This comment has been minimized.

sagivo commented Apr 15, 2015

great! thank you :)

@rleger

This comment has been minimized.

rleger commented May 5, 2015

@kojoru

This comment has been minimized.

kojoru commented Oct 14, 2015

Use super instead of ctrl for ⌘-clicks on macs

@MichalGallovic

This comment has been minimized.

MichalGallovic commented Oct 16, 2015

great guys, thank you :) kojoru thx for mac tip

@shershen08

This comment has been minimized.

shershen08 commented Oct 20, 2015

for MacOS filename that worked for me - 'Default.sublime-mousemap'

@feighter09

This comment has been minimized.

feighter09 commented Jan 27, 2016

you da bomb

@besabellacyrus

This comment has been minimized.

besabellacyrus commented Jan 28, 2016

thanks for this sir, :)

@wellington-everis

This comment has been minimized.

wellington-everis commented Feb 23, 2016

Thank you man!!!!!!!!!!!

@vastsoun

This comment has been minimized.

vastsoun commented Mar 4, 2016

Wow this is great! Good job.

@harry34

This comment has been minimized.

harry34 commented Mar 14, 2016

This shortcut(ctrl+mouse-left-click)'s default behavior is to create multiple cursors, so instead you can use button2, so the combination become like this: ctrl+mouse-right-click.

@Gpzim98

This comment has been minimized.

Gpzim98 commented Apr 3, 2016

Good job. Thank you.

@betomoretti

This comment has been minimized.

betomoretti commented Apr 6, 2016

Nice!!

@bocaben

This comment has been minimized.

bocaben commented May 4, 2016

I added another shortcut so ctrl+right-click will bring you back.

[
    {
        "button": "button1", 
        "count": 1, 
        "modifiers": ["ctrl"],
        "press_command": "drag_select",
        "command": "goto_definition"
    },
    {
        "button": "button2", 
        "count": 1, 
        "modifiers": ["ctrl"],
        "command": "jump_back"
    }
]
@bubersson

This comment has been minimized.

bubersson commented May 8, 2016

Cool, thank you!
Here's how you make the go_to_definition work well with typescript files:

[
    // TypeScript
    {
        "button": "button1",
        "count": 1,
        "modifiers": ["super"],
        "press_command": "drag_select",
        "command": "typescript_go_to_definition",
        "context": [
             { "key": "selector", "operator": "equal", "operand": "source.ts, source.tsx" }
        ]
     }
]

(I prefer this on the command key on my Mac.)

@bradleymarques

This comment has been minimized.

bradleymarques commented May 23, 2016

Works like a charm. Thank you.

@DouglasPioStudiare

This comment has been minimized.

DouglasPioStudiare commented Jul 22, 2016

This very good. Thanks.

@sunalive

This comment has been minimized.

sunalive commented Jul 31, 2016

I'm using Sublime portable version (for Windows) and this (placing the mousemap in SublimeText\Packages\User folder) did not work for me.

I had to place the mousemap file in SublimeText\Data\Packages\User folder to get it to work where SublimeText is the installation directory for my portable version. Data\Packages\User is where I found the keymap file as well.

@SergiiVlasiuk

This comment has been minimized.

SergiiVlasiuk commented Aug 11, 2016

I'm new 'sublime' user i do not know a lot of useful things, but this feature has worked for me from first try.
Great thanks!

@wxs77577

This comment has been minimized.

wxs77577 commented Sep 26, 2016

thanks, good job! it's better to use super to instead ctrl

@AntonyBaasan

This comment has been minimized.

AntonyBaasan commented Oct 21, 2016

Thanks.
It doesn't work for me if I import JS function as default.
I am using Sublime Text 3. Babel JavaScript file.

Click on "beginAjaxCall" works:
import {beginAjaxCall} from './ajaxStatusActions';
Click on "authorsApi" does not work:
import authorsApi from '../api/mockAuthorApi';

The functions imported as below:

export function beginAjaxCall(){
...
}

export default authorApi;

What am I missing here? How to make it work?

@veremey

This comment has been minimized.

veremey commented Feb 1, 2017

@ALL, @sunalive
Write settings work on WINDOWS, pls

@wenyizou

This comment has been minimized.

wenyizou commented Mar 3, 2017

Thanks, works nice on Win10

@com314159

This comment has been minimized.

com314159 commented May 5, 2017

for MacOS filename only - 'Default.sublime-mousemap' worked for me, the default 'Default (OSX).sublime-key' not work

@dimien

This comment has been minimized.

dimien commented May 13, 2017

cool, thnx

@oakbani

This comment has been minimized.

oakbani commented Jul 27, 2017

Not working on windows. Sublime shows it's default behavior of putting multiple cursors

@ezraabc

This comment has been minimized.

ezraabc commented Nov 15, 2017

Thank you! Working great on Windows 10 😃

@axelgomez

This comment has been minimized.

axelgomez commented Nov 22, 2017

Thank you, it works great!

@szekelygobe

This comment has been minimized.

szekelygobe commented Dec 11, 2017

Nice one! Thank you!

@Stark1937

This comment has been minimized.

Stark1937 commented Feb 7, 2018

nice guys! Its wonderful !

@DVLP

This comment has been minimized.

DVLP commented Feb 13, 2018

For people to whom it doesn't work read the instructions like I didn't at first.

You can't just go instinctively to Preferences > Keybindings and change it there. It will not work. You have to go where the Default (Linux/Windows/OSX).sublime-keymap file is and manually make a new file with the same name but saying Default (Linux/Windows/OSX).sublime-mousemap This is overcomplicated and I think all bindings should go to Preferences > Keybindings but the long way works for now!!!

@alannaidon

This comment has been minimized.

alannaidon commented Mar 6, 2018

Not working with me :(

I did:

cd ~/.config/sublime-text-3/Packages/User

vim Default\ (Linux).sublime-keymap

added the code above

[
      { "keys": ["ctrl+alt+a"], "command": "alignment" },
      { "keys": ["ctrl+alt+n"], "command": "advanced_new_file_new"},

      {
        "button": "button1",
        "count": 1,
        "modifiers": ["ctrl"],
        "press_command": "drag_select",
        "command": "goto_definition"
     }
]

Any idea why it's not working ?

@Saboteur777

This comment has been minimized.

Saboteur777 commented May 3, 2018

@alannaidon: you should edit Default\ (Linux).sublime-mousemap instead of Default\ (Linux).sublime-keymap.

@pikeszfish

This comment has been minimized.

pikeszfish commented May 18, 2018

Great!

@fineday009

This comment has been minimized.

fineday009 commented May 23, 2018

@WegDamit

This comment has been minimized.

WegDamit commented Jul 15, 2018

[
    {
        "button": "button1",
        "count": 1,
        "modifiers": ["alt", "ctrl"],
        "command": "goto_definition"
    }
]

if two modifiers, here Ctrl & Alt, are wanted, add them as array, not string ("ctrl+alt")...
IF Ctrl is not used as modifier the drag_select for "press_command" should be removed, too...

@GreLI

This comment has been minimized.

GreLI commented Oct 10, 2018

Unfortunately, it conflicts with editor features like multiple cursors/selection, effectively disabling them. Is there a way to apply this only when definition is available?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment