Skip to content

Instantly share code, notes, and snippets.

@kendellfab
Created August 1, 2013 20:53
Show Gist options
  • Select an option

  • Save kendellfab/6135193 to your computer and use it in GitHub Desktop.

Select an option

Save kendellfab/6135193 to your computer and use it in GitHub Desktop.
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"
}
]
@SergiiVlasiuk
Copy link
Copy Markdown

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
Copy link
Copy Markdown

wxs77577 commented Sep 26, 2016

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

@AntonyBaasan
Copy link
Copy Markdown

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
Copy link
Copy Markdown

veremey commented Feb 1, 2017

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

@wenyizou
Copy link
Copy Markdown

wenyizou commented Mar 3, 2017

Thanks, works nice on Win10

@com314159
Copy link
Copy Markdown

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

@dimien
Copy link
Copy Markdown

dimien commented May 13, 2017

cool, thnx

@oakbani
Copy link
Copy Markdown

oakbani commented Jul 27, 2017

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

Copy link
Copy Markdown

ghost commented Nov 15, 2017

Thank you! Working great on Windows 10 😃

@axelgomez
Copy link
Copy Markdown

Thank you, it works great!

@szekelygobe
Copy link
Copy Markdown

Nice one! Thank you!

@Stark1937
Copy link
Copy Markdown

nice guys! Its wonderful !

@DVLP
Copy link
Copy Markdown

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
Copy link
Copy Markdown

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
Copy link
Copy Markdown

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

@pikeszfish
Copy link
Copy Markdown

Great!

@fineday009
Copy link
Copy Markdown

@WegDamit
Copy link
Copy Markdown

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
Copy link
Copy Markdown

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?

@JorgePalacios
Copy link
Copy Markdown

Thank you very much @DVLP

@zakius
Copy link
Copy Markdown

zakius commented Apr 27, 2019

Is there any way to make it universal? typescript one doesn't work with other file types, default one doesn't work in TS

@batakpout
Copy link
Copy Markdown

Good one! Thank you!

@JamesHarrisonBaggs
Copy link
Copy Markdown

@greksak
Copy link
Copy Markdown

greksak commented Mar 5, 2020

Hi Guys.
I have sublime Text 3 in 3 computers with Ubuntu. It does not work in any.
I did file: "Default (Linux).sublime-mousemap" in ~/.config/sublime-text-3/Packages/User with this content

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

This "shortcut combination" worked to me as multiselect cursor before, but now not. This mean shortcut somehow work. But not as I expected. When I hold Ctrl and click Left mouse on any function name or wherever, nothing happen.
I tried many times Copy-Paste it, restart ST3. I have this plugins:

  • All Autocomplete.sublime-package
  • BracketHighlighter.sublime-package
  • Laravel Blade Highlighter.sublime-package
  • Package Control.sublime-package
  • PHP-Twig.sublime-package
  • SublimeLinter-php.sublime-package
  • SublimeLinter.sublime-package
  • Theme - Kronuz.sublime-package
  • Twig.sublime-package

Any idea, why it doesn't work for me?

@rizkhal
Copy link
Copy Markdown

rizkhal commented Jan 25, 2021

@greksak you must remove "count": 1, to make it works..

@Narven
Copy link
Copy Markdown

Narven commented Sep 10, 2021

...from the future 2021

... no we still have not ended world hunger

But on ST4 on MacOS, and inside the file Default.sublime-mousemap:

[
    {
        "button": "button1", 
        "modifiers": ["super"],
        "press_command": "drag_select",
        "command": "goto_definition"
    },
    {
        "button": "button2", 
        "modifiers": ["super"],
        "command": "jump_back"
    }
]

worked for me

@aejuice-github
Copy link
Copy Markdown

For some reason, it works only on already opened tabs. If the tab is closed it does nothing. It worked before but at some point stopped. Any suggestions?

@mirodilkamilov
Copy link
Copy Markdown

If you want VS Code style, like ctrl + button1 for definition and alt + button1 for selecting multiple lines, then paste this content instead:

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

@huaxlin
Copy link
Copy Markdown

huaxlin commented Sep 3, 2022

macOS Default (OSX).sublime-mousemap in "~/Library/Application Support/Sublime Text 3/Packages/User/":

[
    // ⌘+LeftClick => goto definition
    {
        "button": "button1",
        "count": 1,
        "modifiers": ["super"],
        "press_command": "drag_select",
        "command": "goto_definition"
    },
    // ⌘+RightClick => jump back
    {
        "button": "button2",
        "modifiers": ["super"],
        "command": "jump_back"
    },
    // ⌥+LeftClick => set multiple cursors
    {
        "button": "button1",
        "count": 1,
        "modifiers": ["alt"],
        "press_command": "drag_select",
        "press_args": {"additive": true}
    }
]

@luoye00
Copy link
Copy Markdown

luoye00 commented Jul 30, 2025

How to set it with sublime text v4?

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