Vim EasyMotion for VS Code not activating - visual-studio-code

Does anyone use Vim with VSCode?
For some reason, my <leader> key (space), does not activate the easy-motion plugin (I made sure it is enabled in the settings), but just moves the cursor to the right once.
I am new to VS Code, am I missing something? I still haven't figured out how .vimrc works with VS Code.
TIA!

It's not nessesary to use .vimrc file for vscode unless you want some customized behaviors.
Make sure you've enbaled the easymotion in vsvim settings:
"vim.easymotion": true
(in your settings.json file)
When it comes to VSCode, easymotion will be triggered by double press <leader> key. Different from Terminal Vim, for example: (in your case <leader> is set to space)
space + space + 2 + s
after you press the above keys, your status bar should look like
this.
Hope it would help you get into Visual Studio Code quickly.

As far as I know, vim mode in VS code isn't configured by .vimrc file, instead, it's configured by setting.json. You can find how to configure them in this README.md.
Check that:
"vim.leader"is set to <Space>
go to preference -> Keyboard shortcut in VS code. Make sure that you did not customize any command to any shortcut starting with <space>. (I made this mistake before)
the timeout length of the leader key is pretty short, make sure you press, let's say, 'w' key right after <leader><leader>
I hope this would help

Related

VS Code keyboard mapping is messed up. How to reset/change?

It seems that my VS Code keyboard mapping is incorrect. At first I thought it was a keybinding issue but when I try to change keybindings I notice that the names of the keys VS Code says I'm typing in for the keybind are different from what I'm actually typing. For instance, my backspace key does not delete left as it should. When I try to change the delete left keybind I see that it is already marked as "backspace". When I try to change the keybind, I see that VS Code thinks my Backspace key is actually Alt. I suspect that my keyboard mapping is incorrectly set (perhaps it's set to international or similar). I think the problem is specific to VS Code since I can type normally in terminal.
keybinding example screenshot
Does anyone know how to fix or reset the keyboard mapping in VS Code v1.67.0 for linux?
It looks like you're running into this issue documented here: https://github.com/Microsoft/vscode/issues/50756
The relevant setting to add in your user settings.json is:
keyboard.dispatch: "keyCode"

VS Code with Vim extension: ctrl+d does not go half a page down but instead goes to "Select Environment"

I checked VS Code shortcut bindings, but do not see why "ctrl+d" will open "Select Environment" instead. That does not even appear in the shortcut bindings. Any idea how I can make it go half a page down instead?
I'm assuming you're using the Vim extension and expect it to page down.
If you select one of the environments (like Node.js for me), it should work after.
In case someone ever met this problem again, I solved this problem by entering command mode (press :) and escape.
I still am not sure what happened.

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.

VS Code - Turn off auto close tags, but leave on autocomplete

Recently switched from Sublime Text 3 to VS Code. Overall pleased with the switch except for this one little thing that's just annoying enough to be a dealbreaker if there's no solution. In ST3 if I type, say, a <div>, it doesn't automatically drop in a </div>, which is nice because I'm often pasting it in and don't want it closed right there.
What ST3 DOES do, however, is complete the tag the moment I type </. It autofills div> the moment I type the forward slash. This is the behavior I want from VS Code. I can't find any mention of this anywhere which is completely baffling. I know how to autoclose tags, but that's no good becasue then I have to manually close them. I want VS Code, like ST3, to autocomplete the tag for me, just not immediately.
Go to File > Preferences > Settings, search for html.autoClosingTags and set it to false.
This will make it so when you type <div>, it won't insert </div> automatically, but if you start typing </, it won't close the tag automatically. You can press ENTER to make it autocomplete for you.
Or you can leave this option enabled and when you type <div> and it autocompletes, you can just press CTRL + Z.
More information on this behavior here.
Add this to settings.json to make it work like Sublime Text:
"html.autoClosingTags": false,
"auto-close-tag.SublimeText3Mode": true
Go to Settings, search for "auto closing" and enable/disable these options as needed
Or set them in your settings.json file like so:
"html.autoClosingTags": false,
"typescript.autoClosingTags": false,
"javascript.autoClosingTags": false,
On Windows/Linux - Ctrl + Shift + P
On MacOS - Cmd + Shift + P
In the search box type settings.json
paste the following line there
"html.autoClosingTags": false
A very simple trick i learnt
If you want to disable tags auto completion for just a single task for example. To save a file without vscode adding closing tags. Just set a different language mode for that file.
Change from the inferred one i.e html to Batch, Diff ignore. The options on vscode are many. This will enable you to save the file without addition of any closing tags.
After you are remember to reset the language mode to Auto Detect.
TLDR;
To access language mode-:
Use the command pallete and search Change Language Mode or
Find a shortcut at the bottom right section on Vscode.

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 .