How do I remap the `Alt+Click` action in visual studio code? - visual-studio-code

according to the documentation here I can add multiple cursors in visual studio code by using alt+Click in the editor. Sadly alt+drag is already used by the window manager to move the window around, so visual-studio-code does not get any key events. So how do I change that keyboard configuration in visual studio code? I could not find anything in the default key combinations file.
I am not looking for solution that changes my window manager, I really like that behavior and use it very frequently already for a very long time.

The easiest way in my opinion is:
From the top-level menu, click on
Selection -> Switch to Ctrl+Click for Multi-Cursor
Then you can use Ctrl+Click rather than Alt+Click.
You can see where this is in this screenshot:
My VSCode version is 1.24.1

There is currently no way to do this but already an open issue on GitHub which addresses that.

Related

VSCode some shortcuts not working properly

latest version 1.40.1 on Windows 7 x64. I am developing in Java.
The most common shortcut, "go to definition" F12 and "auto fix" ctrl+dot
I tested it on another computer with 1.40.1. It works properly.
I have follow the key binding troubleshooting guide. When I record my key ctrl+dot.
It shows ctrl+oem_period. Looks like the OS is sending the correct keys to VSCode.
I couldn't find a way to reset VSCode key bindings and do not know what is actually causing this.
What should I do next? Completely reinstall everything is the last resort.
With the command Developer: Toggle Keyboard Shortcuts Troubleshooting, you can see which command is linked to a shortcut. It could happen that an extension is overriding the expected behaviour.
For example, I had an extension overriding the shortcut to reopen a closed tab, which didn't work anymore.
This resolves my issue:
Change your "keyboard.dispatch" to keyCode in the file settings.json
{
"keyboard.dispatch": "keyCode"
}
Your operating system keyboard shortcut is overriding the vscode shortcut. You should check your operating system shortcut key instead.
Just restarted the Visual Studio Code and the keys are working fine.
I was facing the same problem after I updated my Intel Graphics Command Center using Windows Updates.
The Add One Cursor Above/Below shortcuts were not working for me.
I started the Intel Graphics Command Center, and then went to System > Hotkeys tab, Enabled System Hotkeys as shown in the picture below.
I flipped my screen a couple of times using the keyboard shortcuts and then disabled once again.
Then switched back to VSCode and the keyboard shortcuts were working!!
In my case, "cmd+k cmd+0" which helps to fold all regions was not working.
Another extension was using the same shortcut. I followed the steps below to fix it.
Here are the steps to fix this
Press "cmd+shift+p" to open command palette
Type "Preferences: Open Keyboard Shortcuts" and hit enter
Press "option+cmd+k" to start recording keys.
Press the short cut keys that are not working (in my case "cmd+k cmd+0" ). This will list all the instances of that shortcut keys. And there are probably multiple instances of the same keybindings with some of them being used by an "Extension" as shown under the "Source" column.
Remove that and keep only that instance which says "Default" under "Source" column.
Now, you should able to use the default keyboard shortcuts.
Resolved :
Facing similar issue. Several keyboard shortcuts stop working when code starts running.
In my case it was happening because of notepad++ extension. Disabling that extension resolves the issue.
Sometimes this can happen because of change in environment variables. Please check if any recent program installations has made that change
You may also need to check the when clause of the Keybinding. In my case, I was struggling with why "Command+R" wasn't reloading the window on my Mac. By right-clicking on the row of the relevant command in Keyboard Shortcuts, then clicking "Change When Expression" and removing the expression completely, the keybinding now works as expected.
Source: https://github.com/microsoft/vscode/issues/108393#issuecomment-706215895
Try turning on Num Lock, it worked for me.
Extensions you add to VSCode also can override the ordinary behavior of shortcuts. I faced to this problem, I've noticed that the ordinary shortcut command + L which selects the whole line, does not work, and the reason was Live Server extension, which overrides that shortcut, after its deletion shortcut became work properly
I have tried many methods to solve this problem ,not every problem of mine got solved so I use this method after I cant find the solution.
you can first uninstall the VS code and then delete the .vscode file from C=>user=>admin=>.vscode
after that reinstall vscode ,from my end its working fine after doing this.
My issue is niche but never know, might help someone - YouTube Music Desktop player app was hijacking cmd, shift + l for me.
In my case, my Ctrl keys were mapped to the Toggle extension and this extension could not overwrite one of my settings in the settings.json because I had pending changes that hadn't been saved. Once I saved the file, I was able to use the toggle keyboard binding again. I used the guidance from Martin above to determine the cause of the issue.
99% works.
Forget everything that may overrides your keyboard shortcuts. The problems is your keybindings.json file, if you fix it you'll fix your problem.
I found the solution and I've explained it in the following link:
Why vscode shortcuts don't work properly?
Woo, found my issue was Razor Naga stuff. After I updated some of the Razor apps (it has Synapse, Cortex, etc), this issue started happening. Now, I saw these apps are running in the background although I am not using the devices at this time, and once I quit them, VSCode went back to normal thankfully.
In my case, I have installed some "vim keyboard extensions" and others. so I have uninstalled all the extensions related to the "keyboard" i.e. "vim keyboard extension" and now it is working fine. it is recommended to check if you have downloaded any extensions for the "keyboard" in the extensions and uninstall it. It might solve the issue.
This worked for me to fix CTRL+Space "Trigger Suggest". First I found and disabled this setting in: System Preferences > Keyboard > Shortcuts > Input Sources
Then I followed #ryandidevar's instructions and replaced everything for Mac: https://stackoverflow.com/a/72187880/14353462
Finally, I set "Trigger Suggest" in VSCode > Preferences > Keyboard Shortcuts to: CTRL+§ (which is right next to my "Z" key). CTRL+Space just would not be accepted under any circumstance. Now hitting CTRL+§ finally brings up the suggestions!
MacOS users,
This is a default macOS shortcut. VSCode is never getting the meta+shift+L message from your OS. Your OS is hijacking it. You need to disable it.
System Settings > Keyboard > Shortcuts > Services > uncheck: Search with Google
Source: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000435950/comments/360000170990
This is a default macOS shortcut, you can disable it at System Settings | Keyboard | Shortcuts | Services| Search with Google.
https://apple.stackexchange.com/questions/180038/strange-behavior-within-ms-word-using-command-shift-l-launches-safari-sometimes
I just deleted folder in %APPDATA%\Code\ resets whole vs code and fixed my problem with alt + b and other vs code shorcuts not working
For me, It is the keyboard layout setting that causes this. Use English US keyboard setting.

How to hide/unhide comments with Microsoft VSCode?

I have a code with many comments, how can I hide these ones, but no delete, I need them after.
I need to hide all the comments in one click, not a simple collapse one
Can't find such feature as well.
Read this issue from GitHub - https://github.com/Microsoft/vscode/issues/46505
Seems like that VSCode can't do it (from the box) and all people waiting for that feature.
I was looking for a way to do that too as I put way too many comments making it hard to debug... and I came across this https://marketplace.visualstudio.com/items?itemName=eliostruyf.vscode-hide-comments it makes all the comments invisible, but it leaves special characters in place. There are also commands to toggle show/hide.
Hide Comments - Visual Studio Marketplace
We now have an extension for that. On the editor title, a toggle action is available to show/hide the comments quickly.
You can download from inside Visual Studio 2022 called unobtrusive code and it will hide all comments and put "+" symbols on the collapsed line to the left of your code that you can open or close them with. It works great.
*** TO GET THE EXTENSION: ***
I went to the Extensions menu at the top of VS 2022 and chose manage extensions.
Then in the manage extensions window that opens up, choose online then Visual Studio Marketplace. In the search at the top right of the manage extensions window type in unobtrusive code. download it and then exit Visual Studio. You should see a window pop up to install it.
When you start VS 2022 again and open a C# script, it should have all the comments minimized to the "plus symbols" to the left of the code!
Hope it works for anyone wanting to hide their comments.

Middle click in Visual Studio Code for scrolling?

I'm checking out this Visual Studio Code but when you middle-click for scrolling as you would everywhere else it selects code instead of scrolling. Not exactly like a left click but still, annoying for me. Is there a way to solve this issue?
No, unfortunately not (yet). But you can contribute here on github to make it happen.
Since the issue has been reported but not fixed for 5 years, you should upvote that issue, and then use the autohotkey workaround:
https://github.com/qooqu/vs-code-mbutton-scroll-ahk
(You have to hold the middle-button down in vscode and drag the mouse up or down to autoscroll, and it scrolls one line at a time instead of smoothly, but it's much better than nothing.)
(To use: Install AutoHotkey, then you can download and run the linked .ahk file)
There's an extension that allows this kind of behaviour in Visual Studio.
Visual Studio Marketplace Link

Can I do this with a custom Visual Studio Code Extension?

I would like to have an additional feature in Visual Studio Code - essentially the "Scope to This" from the full Visual Studio Solution Explorer.
It is basically a context menu (right click) entry in the File Explorer of Visual Studio Code - which then should limit which files and folders are displayed.
Is such a thing possible with a Visual Studio Code Extension?
I never built an extension for VS Code before and would like to know if this is even possible or if I would just waste my time.
According to the API docs, there is no way to filter visible files in the Explorer like it can usually be done with the files.exclude setting. However, it is possible to open another folder with the workspace.openFolder complex command. This will probably also close all opened editors, and forget about the original workspace root path.
Your extension would need to remember the initial root path and opened editors to undo this "Scope to This" menu, and reopening everything every time could cause quite some lag.
You can't customize the normal explorer view.
However, you can do something like this with custom views. It allows you to create a new explorer view that can list what you want and behave as you want.
For an example implementation, check the vscode-code-outline.
If you can add a context menu entry separately too.

Does VS Code has any shortcut like ctrl+q in eclipse?

Does VS Code (I currently use v1.8.1) has any shortcut like ctrl+q in eclipse?
It returns your cursor to the place where you stopped writing code(very useful for fast code browsing)
and it is different to alt+left which navigate backward
EDIT: I have found that this extension should do that you're asking. I suggest trying it out.
Original:
Out of the box in VS Code, this command does not exist. The list of default shortcuts can be found here, or you can open the keybindings settings in VS Code (ctrl+k, ctrl+s on Windows) and see which commands are available.
If you'd like to suggest this as a feature, you can open a new issue on GitHub or consider creating an extension.
If I understand correctly, you want a command that will move the cursor to where the last edit in a document was made.
This should be possible using an extension that listens to document change events and records the position of the cursor. Then, when the command is issued, it sets the editors cursor to that saved position.
You can also try "Eclipse Keymap" from Alphabot Security, has a lot of eclipse bindings.
I don't believe there is a built-in way to do this, but you could work around it by using an extension such as https://marketplace.visualstudio.com/items?itemName=alefragnani.Bookmarks .