Is there any way to switch windows in VScode via keyboard shortcut when the focus is on the terminal? - keyboard-shortcuts

I would like to switch between windows (vscode) regardless if the focus is on the editor or on (any) terminal. I tried the key binding below in the json file without any luck. Also, dropping the "when" clause or only using terminalFocus doesn't work. It seems I can only switch windows if the focus is on the editor. Would be grateful for any suggestions.
{
"key": "ctrl+w",
"command": "workbench.action.switchWindow",
"when": "terminalFocus || editorTextFocus"
}

In my testing I see two options:
(1) It appears that any other keybinding except Ctrl+W works as expected; or
(2) add your command workbench.action.switchWindow to the Terminal > Integrated: Commands to Skip Shell list in your settings if you want to use Ctrl+W as your keybinding.

Related

jupyterlab keyboardshortcuts: Which selector to use

I'm trying to set 3 keyboards shortcuts in jupyterlab. I go about this via settings / advanced settings editor / keyboard shortcuts, that's the only method I'm aware of.
I'm trying to set:
notebook:run-all-cells
notebook:run-all-above
notebook:run-all-below
I've experimented with the selectors that work for restart-and-clear: "selector": "[data-jp-kernel-user]:focus" and several others, not really understanding what they were to be honest, but I couldn't get it to work. Can someone tell me which selector I need to use here? How does one go about figuring this out?
Thanks
Since you are trying to run cells, presumably having one of the cells selected, I would use [data-jp-code-runner], for example:
{
"command": "notebook:run-all-cells",
"keys": ["F9"],
"selector": "[data-jp-code-runner]"
}
To discover a selector in the future you can search the list of existing shortcuts in the left panel. for example searching for Shift Enter or run keyword brings up:
{
"command": "runmenu:run",
"keys": [
"Shift Enter"
],
"selector": "[data-jp-code-runner]"
},
Alternatively you could:
use just body if you want the shortcut to be always active (even though it may error if executed when focus is not on appropriate element)
(advanced) use web developer inspector tool in your browser to determine the web query (CSS) selector for the element of interest

VS Code Explorer side bar navigation

When I press Cmd + Shift + E I set focus on the explore file tree, and can now navigate my files with the arrow keys.
Enter should active the file but instead it activates the rename command that is normal associate with F2.
It works on windows but not on my macbook. I know how to create a custom key binding. but I can not find the command for activating a file in keybindings.json.
I am using Parallels Desktop 12 for Mac and know that it can cause keyboard binding issues. But I dont think it's the case here.
So do someone have a solution for this or know the command to activate in the keybindings.json file?
Bind the list.select event to enter in your keybindings.json
{
"key": "enter",
"command": "list.select",
"when": "listFocus"
}

How to center the editor window back on the cursor in VSCode?

I'm using VSCode as my text editor. I'm curious, is there a keybinding for centering the editor window on the cursor, when the window is a lot of lines below/above it such that it's not visible on the screen? I've tried looking at the default keybindings by going to FIle > Preferences > Keyboard Shortcuts, but I see no such options for centering the window.
There is no such keybinding / command built-in.
I couldn't stand that either, so I created a VSCode extension. You can find it and install it here on the marketplace. The default shortcut is CTRL + L.
If you are using vscodevim, zz should work.
If you want to always keep the cursor on the center, you can change the setting Cursor Surrounding Lines to a really high number (100 is ok) and that should work.
As #kwood put it, there is an extension Center Editor Window in the marketplace that meets this end.
I would like to make an answer here, to complement that -- even the extension's author did not explicitly state in the marketplace page -- if you would like to change the default key binding (Ctrl+L), you may try put the following lines in the keybindings.json for the keyboard bindings.
{
"key": "cmd+k cmd+c",
"command": "center-editor-window.center",
"when": "editorTextFocus"
},
The above command sets ⌘ Command+K, ⌘ Command+C as the keyboard shortcut.
Apart from that, you may set
"center-editor-window.threeStateToggle": true,
in the settings.json for VS Code settings so that it will switch among three states (center, top, bottom) instead of one (center).

vscode global keyboard shortcuts overriding in extension

I have a set of keybindings in package.json,
{
"command": "md.image",
"key": "Ctrl+Shift+i"
}, {
"command": "md.codeblocks",
"key": "Ctrl+Shift+B"
}
This has a problem with other global keyboard shortcuts in vscode, I want to have this overridden in the extension so these keyboards act as the current keyboard mappings for the language its loaded for.
Is this possible?
In case anyone runs into the same specific example of this that I ran into:
I was trying to use the Ctrl+F command to go forward with the Vim extension in VS Code.
I tried unsuccessfully putting a config with unset! in keybindings.json.
However I found that "vim.useCtrlKeys": true in settings.json allows these sorts of ctrl keys to work in the Vim extension with no other changes necessary.
You can disable existing shortcuts by adding a keybinding entry and prefixing its command with a -. For example, to disable the builtin global shortcut for ctrl+n, add the following entry:
{ "key": "ctrl+n", "command": "-cursorDown", "when": "textInputFocus" }
You can find the default global entries by selecting "Preferences: Open Default Keyboard Shortcuts (JSON)" from the Command Palette.

Problems with Ctrl+Backspace in Sublime Text 3

I regularly use ctrl+backspace in Sublime 3 to delete a whole word, but recently it stopped working. Nothing happens when I try to use it.
I have tried mapping it in Key Bindings - User as
{ "keys": ["ctrl+backspace"], "command": "delete_word", "args": { "forward": false } }
but still no luck. Have also checked that it is not caught by AutoHotKey or other programs running in the background.
Anyone else having the same issue with Sublime 3? Any ideas how to fix this?
Thanks in advance
Check out the FindKeyConflicts plugin, available via Package Control. Once installed, open the Command Palette and type findkeycon until the FindKeyConflicts options appear. Choose All Conflicts and hit Enter. Once the new tab opens and is populated, search in it for ctrl+backspace and see if anything comes up. Once you find the offending plugin, you can use PackageResourceViewer to edit the appropriate .sublime-keymap file and change that key combo to something else.
Good luck!