VS Code Explorer side bar navigation - keyboard-shortcuts

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"
}

Related

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

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.

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!

Adding bookmarks in Sublime Text 2

In Sublime Text 2, I'd like to be able to bookmark a line, so I can have easy access to it.
I'm working on a 2011 iMac, and various sources tell me that the shortcut is supposed to be cmd + f2.
However, when I press that, absolutely nothing happens. It does work however, if I manually go through the Goto menu and add it. Has anyone else experienced the keyboard shortcut failing? Does anybody have any ideas of how to solve it?
Thanks.
For extra info, I think this is the relevant line in the default keybindings file.
{ "keys": ["super+f2"], "command": "toggle_bookmark" },
The point is: F keys on mac are triggered with pressing fn key, so for this case that would work as cmd+fn+f2.