Create a gist now

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.

Show comment
Hide comment
@phackwer

phackwer 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.

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.

Show comment
Hide comment
@sagivo

sagivo Apr 15, 2015

great! thank you :)

sagivo commented Apr 15, 2015

great! thank you :)

@rleger

This comment has been minimized.

Show comment
Hide comment

rleger commented May 5, 2015

@kojoru

This comment has been minimized.

Show comment
Hide comment
@kojoru

kojoru Oct 14, 2015

Use super instead of ctrl for ⌘-clicks on macs

kojoru commented Oct 14, 2015

Use super instead of ctrl for ⌘-clicks on macs

@MichalGallovic

This comment has been minimized.

Show comment
Hide comment
@MichalGallovic

MichalGallovic Oct 16, 2015

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

MichalGallovic commented Oct 16, 2015

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

@shershen08

This comment has been minimized.

Show comment
Hide comment
@shershen08

shershen08 Oct 20, 2015

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

shershen08 commented Oct 20, 2015

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

@feighter09

This comment has been minimized.

Show comment
Hide comment
@feighter09

feighter09 Jan 27, 2016

you da bomb

feighter09 commented Jan 27, 2016

you da bomb

@besabellacyrus

This comment has been minimized.

Show comment
Hide comment
@besabellacyrus

besabellacyrus Jan 28, 2016

thanks for this sir, :)

besabellacyrus commented Jan 28, 2016

thanks for this sir, :)

@wellington-everis

This comment has been minimized.

Show comment
Hide comment
@wellington-everis

wellington-everis Feb 23, 2016

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

wellington-everis commented Feb 23, 2016

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

@vastsoun

This comment has been minimized.

Show comment
Hide comment
@vastsoun

vastsoun Mar 4, 2016

Wow this is great! Good job.

vastsoun commented Mar 4, 2016

Wow this is great! Good job.

@harry34

This comment has been minimized.

Show comment
Hide comment
@harry34

harry34 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.

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.

Show comment
Hide comment
@Gpzim98

Gpzim98 Apr 3, 2016

Good job. Thank you.

Gpzim98 commented Apr 3, 2016

Good job. Thank you.

@betomoretti

This comment has been minimized.

Show comment
Hide comment
@betomoretti

betomoretti commented Apr 6, 2016

Nice!!

@bocaben

This comment has been minimized.

Show comment
Hide comment
@bocaben

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

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.

Show comment
Hide comment
@bubersson

bubersson 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.)

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.

Show comment
Hide comment
@bradleymarques

bradleymarques May 23, 2016

Works like a charm. Thank you.

bradleymarques commented May 23, 2016

Works like a charm. Thank you.

@DouglasPioStudiare

This comment has been minimized.

Show comment
Hide comment
@DouglasPioStudiare

DouglasPioStudiare Jul 22, 2016

This very good. Thanks.

DouglasPioStudiare commented Jul 22, 2016

This very good. Thanks.

@sunalive

This comment has been minimized.

Show comment
Hide comment
@sunalive

sunalive 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.

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.

Show comment
Hide comment
@SergiiVlasiuk

SergiiVlasiuk 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!

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.

Show comment
Hide comment
@wxs77577

wxs77577 Sep 26, 2016

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

wxs77577 commented Sep 26, 2016

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

@AntonyBaasan

This comment has been minimized.

Show comment
Hide comment
@AntonyBaasan

AntonyBaasan 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?

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.

Show comment
Hide comment
@veremey

veremey Feb 1, 2017

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

veremey commented Feb 1, 2017

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

@wenyizou

This comment has been minimized.

Show comment
Hide comment
@wenyizou

wenyizou Mar 3, 2017

Thanks, works nice on Win10

wenyizou commented Mar 3, 2017

Thanks, works nice on Win10

@com314159

This comment has been minimized.

Show comment
Hide comment
@com314159

com314159 May 5, 2017

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

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.

Show comment
Hide comment
@dimien

dimien May 13, 2017

cool, thnx

dimien commented May 13, 2017

cool, thnx

@oakbani

This comment has been minimized.

Show comment
Hide comment
@oakbani

oakbani Jul 27, 2017

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

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.

Show comment
Hide comment
@ezraabc

ezraabc Nov 15, 2017

Thank you! Working great on Windows 10 😃

ezraabc commented Nov 15, 2017

Thank you! Working great on Windows 10 😃

@axelgomez

This comment has been minimized.

Show comment
Hide comment
@axelgomez

axelgomez Nov 22, 2017

Thank you, it works great!

axelgomez commented Nov 22, 2017

Thank you, it works great!

@szekelygobe

This comment has been minimized.

Show comment
Hide comment
@szekelygobe

szekelygobe Dec 11, 2017

Nice one! Thank you!

szekelygobe commented Dec 11, 2017

Nice one! Thank you!

@Stark1937

This comment has been minimized.

Show comment
Hide comment
@Stark1937

Stark1937 Feb 7, 2018

nice guys! Its wonderful !

Stark1937 commented Feb 7, 2018

nice guys! Its wonderful !

@DVLP

This comment has been minimized.

Show comment
Hide comment
@DVLP

DVLP 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!!!

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.

Show comment
Hide comment
@alannaidon

alannaidon 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 ?

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.

Show comment
Hide comment
@Saboteur777

Saboteur777 May 3, 2018

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

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.

Show comment
Hide comment
@pikeszfish

pikeszfish commented May 18, 2018

Great!

@fineday009

This comment has been minimized.

Show comment
Hide comment

fineday009 commented May 23, 2018

@WegDamit

This comment has been minimized.

Show comment
Hide comment
@WegDamit

WegDamit 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...

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

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