I'm configuring keybindings of Visual Studio Code. For accepting suggestions, two keybindings are set by default, but I have no idea why there are acceptAlternativeSelectedSuggestion and acceptSelectedSuggestion as they seem to cause the same effect. So, what is the difference?
{
"key": "shift+tab",
"command": "acceptAlternativeSelectedSuggestion",
"when": "suggestWidgetHasFocusedSuggestion && suggestWidgetVisible && textInputFocus"
},
{
"key": "tab",
"command": "acceptSelectedSuggestion",
"when": "suggestWidgetHasFocusedSuggestion && suggestWidgetVisible && textInputFocus"
},
Experimentally, it affects what happens to the text to the right of the caret if the caret is in the middle of a word during completion.
acceptSelectedSuggestion causes the text to the right of the caret to be kept after the suggestion is accepted.
acceptAlternativeSelectedSuggestion causes the text to the right of the caret to be removed after the suggestion is accepted.
If you feel like further digging, the source code can be found in the following files:
src/vs/editor/contrib/suggest/browser/suggestController.ts
src/vs/editor/contrib/inlineCompletions/browser/suggestWidgetInlineCompletionProvider.ts
Related
I love the keyboard shortcuts offered in Vim Normal mode and find them very helpful but I also like the keyboard shortcuts in normal VSCode. For example all the multi-cursor stuff. like ctrl+d (highlight next occurrence) or ctrl+f2: (highlight all occurrences). For some reason whenever I use ctrl+d or ctrl+f2 it appears to work normally but puts me in visual mode even though I have turned off mouse selection goes into Visual mode.
TL/DR: Basically I just want Vim to act like it is off when in Insert mode but still allow me to go to normal mode with Escape
Current Settings/Preferences
User/settings.json:
"vim.useCtrlKeys": false, //appears to not work for me, I just removed bindings for some stuff with ctrl keys
"vim.startInInsertMode": true,
"vim.mouseSelectionGoesIntoVisualMode": false,
"vim.smartRelativeLine": true,
"vim.useSystemClipboard": true,
User/keybindings.json:
(minus sign in front of command means it is disabled):
{
"key": "shift+alt+down",
"command": "-extension.vim_cmd+alt+down",
"when": "editorTextFocus && vim.active && !inDebugRepl"
},
{
"key": "shift+alt+up",
"command": "-extension.vim_cmd+alt+up",
"when": "editorTextFocus && vim.active && !inDebugRepl"
},
{
"key": "ctrl+d",
"command": "-extension.vim_ctrl+d",
"when": "editorTextFocus && vim.active && vim.use<C-d> && !inDebugRepl"
}
OS: Windows 11 (don't bully me plz)
I would like to toggle the explorer.excludeGitIgnore setting on VS Code. I didn't find and command to toggle that flag. I was wondering whether there might by a command to update any setting.
I was thinking about something like this:
{
"key": "shift+cmd+.",
"command": "setting.edit",
"args": [
"explorer.excludeGitIgnore",
"true",
],
"when": "explorerViewletFocus"
},
How can I open a specific file in a specified split view with an built-in command in VS codium? Is that possible without writing an extension?
I have a project, and I periodically I want to open a pair of files in specific way in split view. Let's mention them as problem1.py and problem1.txt. I want to programmatically open problem1.py in the left side, and the problem1.txt in the right side.
I found an a documentation for the command vscode.open:
vscode.open - Opens the provided resource in the editor. Can be a text or binary file, or an http(s) URL. If you need more control over the options for opening a text file, use vscode.window.showTextDocument instead.
uri - Uri of a text document
columnOrOptions - (optional) Either the column in which to open or editor options, see vscode.TextDocumentShowOptions
label - (optional)
(returns) - no result
In keybindings.json I created following statements:
{
"key": "numpad4",
"command": "vscode.open",
"args": "/home/user/myproject/README.md"
},
{
"key": "numpad6",
"command": "vscode.open",
"args": ["/home/user/myproject/README.md", "1"]
},
Now when I press numpad4, it works perfectly, the readme file opens. But when I press numpad6, I get a notification:
Unable to open '': An unknown error occurred. Please consult the log for more details.
Am I passing parameters in a wrong way? Why it does not detect a filename? And I do not see whare to view a log.
Additional info:
VS codium version: 1.66.2.
I saw a cli option -r, --reuse-window, but it has not control of in which view I want to open a file.
I saw a similar question, but there the author wants to do it from extension, while I would prefer to not write an extension for this problem. Also, as documentation says, I think I do not need vscode.window.showTextDocument, as vscode.open should be enough for my task.
Here is an enum list for available ViewColumn values: https://code.visualstudio.com/api/references/vscode-api#ViewColumn
you can use the extension HTML Related Links use command htmlRelatedLinks.openFile
{
"key": "numpad6",
"command": "htmlRelatedLinks.openFile",
"args": {
"file": "${workspaceFolder}/README.md",
"method": "vscode.open",
"viewColumn": 1
}
}
Combining the #rioV8's solution of using HTML Related Links and #Mark's solution for combining two commands into one, the resulting keybindings.json is the following:
{
"key": "numpad5",
"command": "extension.multiCommand.execute",
"args": {
"sequence": [
{ "command": "htmlRelatedLinks.openFile",
"args": {
"file": "/home/user/myproject/problem1.py",
"method": "vscode.open",
"viewColumn": 1,
}
},
{ "command": "htmlRelatedLinks.openFile",
"args": {
"file": "/home/user/myproject/problem1.txt",
"method": "vscode.open",
"viewColumn": 2,
}
},
]
}
},
I'm trying to bind Clear Console(workbench.debug.panel.action.clearReplAction) to a shortcut, the problem is what's the When condition for checking if the debug console is active?
I've figured this out:
{
"key": "ctrl+l",
"command": "workbench.debug.panel.action.clearReplAction",
"when": "inDebugRepl && textInputFocus"
}
I'm tried each of the following keybindings.json ctrl+enter "command" settings to enable execution of two commands when the .py[thon] script editor extension is active. The single commands work but none of the attempts to associate multiple commands or a macros reference containing multiple commands, work. The later generates a "command 'macros.<macro defined in settings.json>' not found."
Any pointers on how I get multiple commands attached to a single keyboard shortcut definition, specifically what's wrong with how i'm setting up macros approach?
// %appdata%\Code\User\keybindings.json
[
{
"key": "ctrl+enter",
//"command": "python.execSelectionInTerminal",
//"command": "cursorDown",
//"command": [ "python.execSelectionInTerminal", "cursorDown" ],
//"command": "python.execSelectionInTerminal, cursorDown",
//"command": "python.execSelectionInTerminal && cursorDown",
"command": "macros.pythonExecuteLineAndMoveToNextOne",
"when": "editorTextFocus && editorLangId == 'python'"
}
]
// %appdata%\Code\User\settings.json
{
"macros": {
"pythonExecuteLineAndMoveToNextOne": [
"python.execSelectionInTerminal",
"cursorDown"
]
},
.
. .
. . .
}
Adding duplicate of answer raised in comments so it can be accepted to change state of this question to answered.
The fix was to add the #name:macros #publisher:geddski vscode extension which was mentioned in the article i used to arrive at the multi-step macro definitions. It wasn't initially clear that it was a requirement.