How do I get VSCode Vim Extension to Control VSCode Keybindings? - visual-studio-code

I am new to VSCode from Vim.
I am trying to get Vim to run the VSCode shortcuts and I can't seem to figure out how to get it going.
for example:
In Vim i use <leader>t to open a terminal below. In VSCode this is Ctr+Shift+
or <leader>h and <leader>l to switch between splits is Ctr+1 and Ctr+2 in VSCode
I have tried remapping the Vim keys to the VSCode commands like this:
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["<leader>", "h"],
"after": ["<C-1>"]
},
]
but it doesn't seem to work.
Any help you can provide would be greatly appreciated!

Related

VSCode colon open command palette

On my Mac OS, I install VIM for vs code.
After press colon ':', vs code command palette pops up, no enter vim command on status bar. And on status bar a string 'workbench.action.showCommands' shows. I think that indicates somewhere I set up colon as a shortcut to vscode command.
VIM extension works fine on my Windows.
Where can I find the wrong settings and get vim colon work?
There is a key mapping setting for VIM extension in my settings.json. Can't remember where it is from. Remove it solves the problem.
{
"before": [":"],
"commands": [
"workbench.action.showCommands"
]
},

how do i change escape vim key binding to jk or something else in vscode. NB. vscode not vim editor

resources available on the web are only touching on vim editor. I am new to vim and I don't want to mess with my workspace settings. How do I go about changingg or keeping esc and adding jk as an optional key binding to leave insert mode in Vim in Vscode.
You should change the vscode json settings.
To do that Press F2 or Ctrl+Shift+P to open vscode commands
enter image description here
then you have to writte this:
"vim.insertModeKeyBindings": [
{ //exit insert mode
"before": [
"j",
"k"
],
"after": [
"<Esc>"
]
}]
This code is mapping jk as .
For more info on what you can do with vscode settings I recomen visiting vscode vim github enter link description here

VS Code terminal history search, Windows, Powershell

since version 1.43 the ctrl+r r keyboard shortcut has stopped working for powershell history searches. Is there another way to search in recently used commands?
Also see https://stackoverflow.com/a/70900927/836330 for how to bring up a QuickPick panel with the recent terminal commands (powershell is supported).
and
https://stackoverflow.com/a/62203544/836330 or https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_70.md#run-recent-command-as-a-replacement-for-reverse-search
I can't reproduce your issue. But you could try this keybinding in the meantime:
{
"key": "alt+r",
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "\u0012" }
},
That sends a Ctrl+R to the terminal. Focus can be anywhere. That should trigger the reverse search of previous terminal commands. Does it do that for you?
See related info: Make a keybinding to run previous or last shell commands

cmd+c is not working on Visual Studio Code

I have following in settings:
{ "key": "cmd+c", "command": "editor.action.clipboardCopyAction",
"when": "textInputFocus" },
This is driving me crazy, have tried everything but am unable to make copy command work in Visual studio code. I have to write click and then select copy. Shortcut does not show in VSC. Does anyone know why?
Open your Keyboard Shortcuts by going to File > Preferences > Keyboard Shortcuts.
In the search bar at the top, type "cmd+c" to search for all shortcuts using those two keys. Now look at the "When" column for all instances of "textInputFocus". You need to make sure that the only command mapped to cmd+c during textInputFocus is the Copy command.
Below is an example where ctrl+c will fail to copy on my Windows setup because a second command is mapped to ctrl+c during textInputFocus.
I don't know why, but in my case I needed to remove the following default keybinding in order for Command+C to start functioning again, therefor my keybindings.json file now looks like this:
[
{
"key": "cmd+c",
"command": "-search.action.copyMatch",
"when": "fileMatchOrMatchFocus"
}
]
(Perhaps using VSCode on a Mac machine and a Linux machine is related, however but this is a wild guess).
In my case with macOS (every time after cmd+C had clicked the behavior was like the keyboard turned on "insert" mode). I deleted the default shortcut, and without specific changes turned back the totally same shortcut, after restart VSCode all works fine

Running simple terminal commands in command palette VS Code

Is it possible to run simple terminal commands in Command Palette? Or an extension for it?
For example, something like rm unwantedfile.txt would be super useful to do in via command palette rather than having to open up the integrated terminal or do the task via mouse (mainly interested in not having to take my hands off the keyboard).
I know there's Edit with Shell Command, but it doesn't appear to be able to edit outside the file itself.
You can either use VS Code built-in functionality using shortcuts. Just add to keybindings.json:
{
"key": "cmd+shift+R",
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "clear; rails server\u000D"
}
},
Or you can take a look at this extension, Command Runner, that does exactly what you're looking for.