VS Code keybindings command to update any setting - visual-studio-code

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

Related

Difference between "acceptSelectedSuggestion" and "acceptAlternativeSelectedSuggestion" in VSCode keybinding config

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

VSCode Vim Addon: How do I set up Insert mode to basicity be normal VSCode (Vim disabled)?

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)

What is the command to open a file in specified ViewColumn in VS Codium?

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,
}
},
]
}
},

VS Code task to toggle the status bar on debug execution

I prefer to hide the status bar in VS code but one nice feature is that it changes colour when your program is ready to debug. This is good when there is a lengthy build step as part of the preLaunchTask. I would like to unhide and hide the taskbar using tasks.json. The internal command is
workbench.statusBar.visible true
But I am not sure how I can execute this in a task by vscode
{
"label": "debug with statusbar",
"type": "process", // ?
"group": "build",
"args": [ true ],
"command": "workbench.statusBar.visible",
"dependsOn":["npm: build"]
},
{
...
It appears a custom task can either execute via shell or as a process. Is there a way to call vscode via one of these methods and execute the internal command? Or is there another way to achieve what I would like?
Editing the settings file seems to do the trick since VS Code watches it in real time.
{
"label": "debug with statusbar",
"type": "shell",
"group": "build",
"args": [
"-i",
"'/\"workbench.statusBar.visible\": false/s/.*/ \"workbench.statusBar.visible\": true/'",
"/home/myuser/.config/Code/User/settings.json"
],
"command": "sed",
"dependsOn":["npm: build"]
},
Then an equivalent task can be used for postDebugTask

Visual Studio Code 1.17.1 Open in Browser without opening terminal

Looks like an old question, but no proper answers found.
I've looked at here and here.
Right now, I can open Chrome by doing this:
task.json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"taskName": "echo",
"type": "shell",
"command": "echo Hello"
},
{
"taskName": "Open in Chrome",
// "type": "process",
"windows": {
"command": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
},
"args": ["${file}"],
}
]
}
keybindings.json:
[{
"key": "ctrl+alt+g",
"command": "workbench.action.tasks.runTask",
"args": "Open in Chrome"
},]
Note that I don't even need type: process to make it run and can only run it using my own key binding. If I use ctrl+shift+B (Windows), it'll allow one task only.
However, every time I run the task, the terminal is also opened with: Terminal will be reused by tasks, press any key to close it. which is repetitive and not really helpful for front-end work.
Is there a way to turn that off?
I've tried adding:
"presentation": {
"reveal": "never" //same with "silent"
}
to the task in task.json but it doesn't work.
Answer to close question:
The easiest way is to use an extension like this one: https://marketplace.visualstudio.com/items?itemName=techer.open-in-browser