microsoft/vscode

Allow customization of mouse shortcuts

Tyriar opened this issue ยท 283 comments

Some users would like to be able to customize not just pure keyboard shortcuts but also mouse + modifier ones. These are currently hard coded, for example alt+click to add a selection.

See #3091 for some more context.

+1

I would like to do shift+cmd+leftMouseButton for Peek Definition, would be a perfect combination for me.

+1

I've found an interesting performance implication resulting from the current defaults/lack of configurability. Consider the hard-coded modifier associated with the "peek definition" functionality. If a plugin must do some work to provide the definition, it's very likely VSCode will ask plugins for definition information even when the user has no intention of obtaining it. As I describe in microsoft/vscode-go#257 (comment):

For example, with the cursor resting still in the editor area, pressing โŒ˜ instantly invokes the GoDefinitionProvider, even when โŒ˜ is immediately used in a chord for some other command (e.g. copy, paste, opening the command palette, etc.).

This means calls to godef are happening when the user is pressing a very common key with no intention of obtaining contextual hover information.

When using vscode-go, this means significant extraneous energy usage which could be avoided almost entirely by providing modifier key settings for "peek definition". Not only would the feature be convenient and allow for better host OS GUI integration, but VSCode would be more CPU-efficient for common usages.

+1 โ€“ Atom, Sublime and jsbin.com (presumably others, too) all allow creation of multiple cursors with โŒ˜+click (on a Mac, at least). It'd be good to be forced to learn as few new shortcuts as possible when switching to a new editor.

I'm just completely avoiding using alt+click to add cursors until I can customize to make Windows and Linux consistent. Don't want to build muscle memory when it's going to change later.

@alexandrudima any thoughts on when you could get to this? It's blocking adding cursors via mouse on Linux. I can take a shot at it if you give a high level approach.

+1 I just discovered VS Code and I'm loving it, but as a long time Sublime Text user on Linux, I'm missing the ctrl + click ability. Would love to be able to customize mouse shortcuts.

From @ChristopherHaws in #6853

  • VSCode Version: 1.1.1
  • OS Version: Windows 10 Pro

In Visual Studio (full version), I tend to turn off the Ctrl+LeftMouseClick go to definition feature. I personally prefer to have Ctrl+LeftMouseClick select the entire word under my mouse cursor.

From what I can see, mouse events are not configurable at the moment, and they are also not possible to override with extensions (to the best of my knowledge). It would be really nice to have a mouse mapping configuration file. Sublime Text has this (although it is sort of a hidden feature that is not exposed through the UI). Just as an example, my sublime text mousemap file looks like this:

[
    {
        "button": "button1", "count": 1, "modifiers": ["ctrl"],
        "press_command": "drag_select",
        "press_args": {"by": "words"}
    }
]

+1 for customization.
I'd like using CTRL to multi-select instead of alt.

I would like to note, that adding cursors with the mouse is impossible on Linux, because alt+click is already used to move the window around (at least on KDE and XFCE), and therefore the alt+click behavior doesn't reach the code editor at all. So I would also suggest to change the default binding to something that doesn't conflict with key combinations of major window managers. Ctrl+Alt+click could work,

I would like to note, that adding cursors with the mouse is impossible on Linux, because alt+click is already used to move the window around (at least on KDE and XFCE), and therefore the alt+click behavior doesn't reach the code editor at all. So I would also suggest to change the default binding to something that doesn't conflict with key combinations of major window managers. Ctrl+Alt+click could work,

Please don't change the default. Using Alt to move Windows around is a bad default, e. g. Inkscape also has problem with this. The Windows key is much better suited for this, as it is more often used for "window manager" shortcuts, e. g. on Windows. Furthermore even the name makes more sense: "Windows key" -> "move windows around". It's also GNOME's default.

IIRC the choice of using Alt as the default for this was also a workaround, because the Windows key didn't act as a real "meta" key. Last time I checked I still couldn't map the Windows key to open the menu in XFCE and move windows around with it at the same time.

@jhasse Ok, I think that window manager stuff should all be done with the windows key modifier is a pretty good argument. But what do you mean with "Last time I checked I still couldn't map the Windows key to open the menu in XFCE and move windows around with it at the same time."? Do you want the windows key to be a modifier and a non-modifier at the same time?

But what do you mean with "Last time I checked I still couldn't map the Windows key to open the menu in XFCE and move windows around with it at the same time."? Do you want the windows key to be a modifier and a non-modifier at the same time?

I want to open the menu by pressing the Windows key (only) while still being able to bind key combinations with it and move windows around.

Let's not get to offtopic though. This issue is only about allowing customizations which - I assume - nobody objects to.

Ok, as long as we all agree here, that not being able to customize mouse shortcuts is bad, everything is fine. I might still say though, that at the moment I am not using VS-code anymore at all, and this issue is related to it.

There is a way to override alt+mouse for window modifiers using xfwm4-tweaks-settings.
screenshot_2016-10-21_09-30-43

But what @jhasse is point to is what should happen if you already have bound to open the xfce menu. If you have any keybinding for the Windows key alone Super L then once pressed, only that event is triggered and nothing else. Currently xfce defaults have nothing bound to Super L, and has ctrl+esc is bound to the window menu command xfce4-popup-whiskermenu.

I do still think that there should be a configurable way to address mouse bindings in vscode directly.

For now a workaround is to change the window manager's accessibility key from alt to super as in the image above.

@anchepiece I am not going to change my window manager settings, nor do I think that this can be barely seen as an appropriate workaround. Seeing this as an appropriate workaround is an insult to all people who got used to work with this setup for years. I won't cange my system shortcuts, just because of a stupid text editor get's in conflict with those keys, I rather avoid using the text editor.

@krux02 Completly agree. I tried it myself when it was suggested and couldn't get the hang of a new keybinding. It's would be much better to leave customization to the user.

This fixed my xenial.
gsettings set org.gnome.desktop.wm.preferences mouse-button-modifier "<Super>"

I am not sure when this feature was added, but I was able to make Ctrl+Left Click select the word under my cursor instead of going to definition.

[
    { "key": "ctrl+[mouse button]",            "command": "cursorWordLeft",
                                               "when": "editorTextFocus" },
]
dvlsg commented

@ChristopherHaws any idea where the [mouse button] definitions are declared? Or any chance you know what the binding is for a middle mouse click? I would love to try setting column selection to middle click + drag.

+1

+1 Please at least map 'multiple cursor' to an additional key map as a workaround until something gets sorted out. This was opened in Feb and most people probably just need a way to make multiple cursors in linux.

+1

Please add a reaction to this issue instead of posting "+1".

This was opened in Feb and most people probably just need a way to make multiple cursors in linux.

Multiple cursors already work fine with some DEs (like GNOME 3) on Linux. For others, see #3130 (comment) for a workaround.

@jhasse I am sorry to repeat myself, but that is a very bad workaround, that can not be seen as an ok-ish solution at all. It could only be seen as a temporary solution to show that in theory multiple cursors are technically possible, but not on something you could recommend anybody to to in practice. I am really sorry to react this way, and it might be annoying: Either you are honest and say do don't care enough because you don't think there are enough people who would benefit for the amount of work, or you fix it properly. But don't reference workarounds like that and pretend it is fixed when it is not. I am not paying for this product, so I am ok when you say you don't care, but I do care when you lie to yourself that this is not really a problem.

@jhasse last time I checked, adding a reaction doesn't make updates to the issue appear in the "participating" section of GitHub notifications. Posting a +1 comment served two purposes for me.

@krux02 You're right, a workaround is only a temporary solution. Just wanted to point out that saying "multiple cursors don't work in Linux" isn't correct. It's rather that multiple cursors don't work with some DEs.
If you globally grab the Alt key on Windows, adding multiple cursors with the mouse won't work there, too.

@sharwell What about subscribing to the issue in addition to adding a reaction?

@jhasse Subscribing puts the notification in the top category here. Replying puts it in the bottom category:

image

I haven't had any of the workarounds that I've researched work, and I really wanted them to. I'm on Linux Mint Sarah with Cinnamon. Honestly the quickest workaround is just go back to my atom setup. I need to code, not jack with desktop settings and cross my fingers.

I have found a horrible workaround for this issue (For Windows at least). You can install AutoHotKey and use the following script which will switch only Ctrl+Click and Alt+Click.

; Switches the Left-Control-Click and Alt-Control-Click shortcut for VS Code.
; Setting for allowing dynamic titles
SetTitleMatchMode, 2

#If WinActive(" - Visual Studio Code")
  ^LButton::Send !{Click}
  !LButton::Send ^{Click}
  Return
#If

I agree that Mouse Shortcuts should be built into VSCode, I rely on them daily as well. The solution I found doesn't work when clicking on words with a linked definition.

+1 for those who come from sublime / atom and would like to use cmd+click when adding multiple cursors or the cmd+drag for dragging cursors

+1 this would be awesome!!!

+1 miss cmd+click for new cursors from sublime - prefer not to use option + click

+1 so I can bind mouse buttons 3 and 4 to workbench.action.navigate*

ackvf commented

@ChristopherHaws the [mouse button] does not seem to be working these days. What is the exact syntax of the command? #3130 (comment)

@vferko It seems this workaround was removed at some point. I'm not sure when. =/

+1

The inability to rebind mouse+modifier controls is a deal-breaker for me, I can neither use nor recommend vscode to people who aren't VStudio users already. This is very unfortunate, as I really like the fast&solid feeling of vscode. Until I found this problem I was completely sold and willing to begin the process of switching over to vscode.

Remapping muscle memory for the most basic platform modifiers is too much to bear, I'll be staying with Atom until this is fixed. On a Mac: cmd-click adds to discontiguous selections; alt-drag on a selection copies that selection; otherwise alt-drag creates rectangular selections. Note: when creating rectangular selections the default is NOT to extend the selection from the previous insertion point, that capability should be placed behind a user setting flag.

Thanks for all your work to date, vscode is really nice! I'll be subscribing to this issue and returning at warp speed when it's successfully resolved.

+1, I'm using vscode in Arch Linux (Openbox), I can not use mouse navigation feature (back/forward) but this feature works fine in chrome and PCManFM file manager. I guess maybe button mapping is different in vscode. So, if I can remapping the button action, manually change it's behavior then I can fix the problem, it would be the best.

I'm using vscode in Arch Linux (Openbox), I can not use mouse navigation feature (back/forward) but this feature works fine in chrome and PCManFM file manager. I guess maybe button mapping is different in vscode. So, if I can remapping the button action, manually change it's behavior then it would be the best.

Best would be if it worked out of the box, don't you think?

please subscribe to this issue to help bump it up in the queue, thanks

๐Ÿ‘

I also really would like the option to rebind mouse click events...this Option-Click for Multiple Cursors conflicts with all my other software...

xster commented

Indeed if just binding the forward/back mouse buttons to workbench.action.navigate... is an easier sub-problem, it would be great to have that as a feature to start with

+1 - So used to control click selecting a word that this is becoming actively annoying for me.

I also would like to see that. I would like to replace "go to definition" with "go to type definition" on cmd+click

Another candidate is being able to customise the swipe gesture that we just introduced via #4803

+1 so I can bind mouse buttons 3 and 4 to workbench.action.navigate*

I don't think I will choose to use VSCode until this issue is resolved.

dunno if this is related, but i really want to disable ctrl+click on links...currently when you ctrl+click on a link in an html file, it opens the link in your standard browser...this "feature" is really a pain in the ass for me, i always want to copy a link with ctrl+c and when i'm doing it quick i already have ctrl pressed before clicking the link to select it and then my browser pops up and the tragedy starts :(

+1 running a Linux VM inside my mac, can't remap the mouse shortcuts to be more like those outside of the VM

+1 Essential feature

i need this to, go to change.org? ๐Ÿ˜‚

Change drag windows with Alt for Kubuntu (16.04):
Settings -> System Settings -> Window Management -> Window Behavior -> Window Actions -> Modifier Key -> change to "Meta"

using the cmd key to add multiple selections is working now for mac !!

thanks to all !!!

eh @ajoslin103 that wasn't actually the intent of this issue.

We should try to find a way to customize the interaction, instead of being given a hardcoded default.

For instance, cmd + click would be super useful to Peek as with most other editors.

Reducing mental tax, thats what we should strive for with keyboard shortcuts!

while I totally agree with you in spirit, this singular issue was the only thing keeping away from vsCode, lo these many moons -- and it took so long to find the problem, locked in an issue at the bottom of a chain (behind a door marked: beware of the leopard!)

I agree that a way to customize mouse+key interaction would be fabulous, I'm still frustrated by the selection extension behavior.

But at least I'm finally here, slowly picking my way through the forest of extensions and options trying to get back to the [nearly] 'thoughtless editing' I'd had with my prior editor.

Please forgive my tunnel vision

How this is going ?
When can we expect a released of this feature ?
I would love to change shortcut like ctrl+maj+mouse for block selection to alt+mouse !

+1, really want to get rid of the "Ctrl+Click => go to definition" binding.

I want to get rid of ctrl click go to definition as well, and instead use it to select the whole word. This is a feature I constantly used in vs and would use it everyday in vs code.

how is this not out yet....?

@lopugit this is an open source project, feel free to contribute to it.

As someone that contributes on a series of projects myself, it doesn't help at all when people post things like "why isn't this in the library?" "why doesn't this exist? It's needed!", etc.

Providing constructive feedback along with +1's for the root issue is what will help drive development.

Don't be entitled, the source code is open, pull your keyboard out and submit a PR if its that urgent.

For the record I'm all for this feature its just annoying to see people demand features for free software.

@oshalygin

sorry that I sounded entitled, It's now 7am and I've just been up all night working on my own projects, I didn't realise this was open source, I thought it was a microsoft project?

My comment only comes from the perspective of, jeez, ctrl+click not being an editable shortcut? Ya feel?

I am working on a few things to contribute to the open source community, I just wanted to add my thoughts to this feature here, every comment can be seen as good discourse.. kind of..

Idk, I'm super tired, peace ;)

@lopugit Well, since we are on GitHub here, yes, this is open source. ๐Ÿ˜…

@Tyriar I notice this is listed as backlogged, to your knowledge, is there a branch where anyone has begun working on adding "Mouse" bindings as customization options? It seems the conversation for this feature has been going on for a while, so I'm assuming its a fairly complex change.

No branch AFAIK. There has been a little movement on this; the editor.multiCursorModifier setting allows you to swap the multi-cursor and follow definition/link modifiers. There is no keybinding.json-like file for mouse bindings though which I imagine the solution to this will look like. I think this is mainly blocked on @alexandrudima freeing up who has many competing priorities.

I would like to use Mouse 4 + 5 (side buttons) for "navigate back" + "navigate forward". Already works in the browser and other IDEs. So please add mouse shortcuts =)

+1

Is everyone read this feature request???
+1

Seriously, please add support for mouse buttons in keyboard shortcuts!

It's coming on 2 years now! Why isn't this a feature yet! Please allow us to use mouse buttons in key binding

I wonder whether it would be easy to add a temporary change to allow column selection in Linux, such that Ctrl+Alt+click (just following the suggestion of krux02) also performed box/column selection in addition to Alt+click, which is blocked by the Linux Window managers? If mouse button customisation is added at some point, this temporary change could then be removed, but in the meantime it would relieve the biggest frustration I have had with using VS Code on Linux.

How long should we wait for this BASIC feature? Another year? It is a CORE BASIC COMMON feature like ENTER or DELETE?
Oh, my god whats going on... People will fly to Mars, and we fighting for mouse keyboard shortcuts. All other editors have this feature on board. But the new, cool kid on the block is behind...

I agree, this is a very basic feature, I dont understand whats going on...
We NEED this feature

You guys realize you're using a completely free tool that you can contribute towards right? I dont think anyone in the community is against a PR with this "basic feature" ๐Ÿ“„

@Thargarius @DoCode

I'm not a perfect Atom/Electron dev.
Anybody here, who can fix or start fixing this issue?

I think here is the Atom pendant.

+1

i'd like to press Mouse2Click (middle mouse button/scroll wheel) to navigate to declaration instead of Ctrl-Mouse1Click

i'd like to press Mouse2Click (middle mouse button/scroll wheel) to navigate to declaration instead of Ctrl-Mouse1Click

The ability to middle-click to open the definition of a method or variable would be nice, it's something I got used to in the GameMaker IDE.

It would be great to have the option to disable the middle mouse button double click paste function.

If VSCode had macro capabilities, this feature could probably be added in via a macro.

PLEASE go to issue #4490 and up-vote it (click on the thumbs-up button) and add your support!

#4490

I'd like to use the trackpoint on my thinkpad to scroll when pressing ctrl (like middle click emulation, ubnutu)

Is it possible to use shift+command and left button mouse click instead of command+left button mouse click or we need to ship this feature first?

I think this would be a nice feature, I would like to bind ctrl+mouse wheel to scroll forward and backward through time

I think this is what I'm looking for...

I really just want to be able to use the 'back' and 'foward' buttons on my mouse to equate to the keyboard shortcut actions 'Go Back' and 'Go Forward' respectively. It seems right now I cannot assign the mouse buttons to these. I'd even settle for a hardcoded solution so I can jump through my code!

Hey @nerael , totally agree. I've solved this issue by binding my mouse buttons to emit keyboard shortcuts that perform the 'Go Back' and 'Go Forward' actions in VSCode. It's easy to do this in Logitech's software, but there are ways to do this on Windows / OSX even if it is not supported by the device manufacturer.

Note that this is only a personal workaround and software level support would be ideal, but this can work in the meantime.

@jsonMartin

Thanks... this led me to a workaround. i approximated it this way
https://thecrumb.com/2015/06/03/xbindkeys/index.html

EDIT - this was also a very helpful tutorial about configuring xbindkeys
https://blog.hanschen.org/2009/10/13/mouse-shortcuts-with-xbindkeys/

My ~/.xbindkeysrc file is:

# VSCODE MOUSE BINDINGS FOR CODE JUMPING
# 'Go Back'
"xte 'keydown Control_L' 'keydown Alt_L' 'key minus' 'keyup Alt_L' 'keyup Control_L'" 
b:8
# 'Go Forward'
"xte 'keydown Control_L' 'keydown Alt_L' 'key equal' 'keyup Alt_L' 'keyup Control_L'" 
b:9

This is because my 'Go Forward' has been bound to ctrl + alt + equals. b:8 and b:9 are keycodes for my mouse buttons for forward and back!

EDIT - in case it wasn't clear, I'm using latest Ubuntu LTS as of this writing, not windows or OSX

I just want to be able to disable my mouse buttons in Visual Studio Code from doing anything as I use one of them for my push to talk key.

So why is there seemingly no answer or progress here? (I have not seen any comment from a collaborator, sorry if that's not true)

Is it an upstream issue of electron? Is it just not an important feature on the Roadmap?

+1

Hey @mhh1422 just a friendly reminder that if you are posting on a github issue, everybody subscribed will get an email.

If you have nothing constructive to add but want to increase awareness please use the reactions.

For everyone I spammed with this message, โค๏ธ

@philiiiiiipp I like knowing how long this is taking though

+1

+1

@lopugit @Nemesis19 @DeadByElpy

Please add the +1 to the original issue at the top.

You can get notified without commenting by pressing the "Subscribe" button on the top right of this page.

This could be useful when you want to bind go back command with back button in mouse, this shortcut is widely used in web browser, and I believe that Visual Studio also has it.

Would be really nice to use "Alt + Scroll Up / Down" to increment / decrement numbers or loop through enums or something like this.

XeonG commented

damn yes we need to able to use mouse buttons in the keybindings.. it would solve a lot of issues like being able to replacing the rubbish shortcuts like {
"key": "ctrl+pagedown",
"command": "workbench.action.nextEditor"
}
with ctrl+mousewheel down etc....

...done mousewheel tab switching.. so much better.

please get on this, it's about time already.

Hope this task is still on the table. I'd like to modify the SHIFT-ALT-LeftMouse "column select" combo into just ALT-LeftMouse...

I am switching from JetBrains products because of work and trying to adapt VSCode as much as possible to my previous workflow.

I used alt+leftclick on any highlighted text to get to the QuickFix menu. In the other editor it would be stuff like fix spell check typos, fix missing imports, simplify code, etc. All this actions are buried under the - now massive - right click menu.

Since I use a rollermouse because of disability this becomes harder than normal since now I have to do a wierd movement to reach the same actions.

Having the ability to customize such things would greatly improve my comfort.

I hope someone gets around to this.

Happy holidays!