microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
160.93k stars 28.23k forks source link

Allow customization of mouse shortcuts #3130

Open Tyriar opened 8 years ago

Tyriar commented 8 years ago

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 https://github.com/Microsoft/vscode/issues/3091 for some more context.

aegyed91 commented 8 years ago

+1

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

jtremback commented 8 years ago

+1

ironcladlou commented 8 years ago

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 https://github.com/Microsoft/vscode-go/issues/257#issuecomment-198993769:

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.

davidpmccormick commented 8 years ago

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

Tyriar commented 8 years ago

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.

JulieMarie commented 8 years ago

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

Tyriar commented 8 years ago

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"}
    }
]
be5invis commented 8 years ago

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

krux02 commented 7 years ago

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,

jhasse commented 7 years ago

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.

krux02 commented 7 years ago

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

jhasse commented 7 years ago

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.

krux02 commented 7 years ago

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.

anchepiece commented 7 years ago

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.

krux02 commented 7 years ago

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

anchepiece commented 7 years ago

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

1415926535 commented 7 years ago

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

ChristopherHaws commented 7 years ago

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 7 years ago

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

wmerussi commented 7 years ago

+1

seminull commented 7 years ago

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

sharwell commented 7 years ago

+1

jhasse commented 7 years ago

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 https://github.com/Microsoft/vscode/issues/3130#issuecomment-255382002 for a workaround.

krux02 commented 7 years ago

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

sharwell commented 7 years ago

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

jhasse commented 7 years ago

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

sharwell commented 7 years ago

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

image

seminull commented 7 years ago

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.

stoikerty commented 7 years ago

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.

reachtrevor commented 7 years ago

+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

thiagoh commented 7 years ago

+1 this would be awesome!!!

mattcdavis1 commented 7 years ago

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

joerohde commented 7 years ago

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

ackvf commented 7 years ago

@ChristopherHaws the [mouse button] does not seem to be working these days. What is the exact syntax of the command? https://github.com/Microsoft/vscode/issues/3130#issuecomment-263780725

ChristopherHaws commented 7 years ago

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

huo-feng-ding commented 7 years ago

+1

ajoslin103 commented 7 years ago

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.

ThorQin commented 7 years ago

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

jhasse commented 7 years ago

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?

ajoslin103 commented 7 years ago

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

robvanpamel commented 7 years ago

:+1:

jsonMartin commented 7 years ago

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 7 years ago

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

psychicteeth commented 7 years ago

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

farfromrefug commented 7 years ago

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

bpasero commented 7 years ago

Another candidate is being able to customise the swipe gesture that we just introduced via https://github.com/Microsoft/vscode/issues/4803

tschieggm commented 7 years ago

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

nnmrts commented 7 years ago

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 :(

kgroat commented 7 years ago

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

Herteby commented 7 years ago

+1 Essential feature