Run custom commands as run configurations in Visual Studio Code - json

I'm trying to figure out how to make a custom run configuration in Visual Studio Code, and am not succeeding in finding any documentation describing my use case.
I want to make a Run Configuration that runs arbitrary commands that I can set to run my code. This is neccecary because the language I am using doesn't have extensions providing run configurations.
I did find that this is possible with tasks, but I cannot figure out how to run a task by pressing F5 (like you would with a run configuration).
So, this is what I am looking to do: Define something that will run a command (run.exe ${currently selected VSCode file}) when I press F5.

Define this task
{
"label": "Run current",
"type": "shell",
"command": "run.exe ${file}"
}
Redefine the F5 keybinding in keybindings.json
{ "key": "F5", "command": "-workbench.action.debug.start" },
{ "key": "F5", "command": "-workbench.action.debug.continue" },
{
"key": "F5",
"command": "workbench.action.tasks.runTask",
"args": "Run current"
}

Related

vscode open CMD with the key binding CTRL + SHIFT + C

I know there are bunch of questions for this one, but none is working for me.
Until yesterday, pressing CTRL+SHIFT+C used to open CMD at the project level folder, but nothing happens since this morning.
I guess something in VScode keybinding settings has been changed accidently, so I tried to use various When expressions but still no luck.
My vscode keybinding settings look like the following.
Could anyone let me know what is wrong with it please ?
// Place your key bindings in this file to override the defaultsauto[]
[
{
"key": "ctrl+shift+c",
"command": "workbench.action.terminal.openNativeConsole",
"when": "editorFocus"
},
{
"key": "ctrl+shift+c",
"command": "-workbench.action.terminal.openNativeConsole",
"when": "!terminalFocus"
}
]
It was the issue on vscode 1.57 for about a week, but it is working now with the latest version.
Good Job VSCODE!

Is it possible to have a global launch.json file?

I am using Don Jayamanne's Python extension and it is working well. The only issue I have is for every project I work on, I have to copy the \.vscode\launch.json file. I was wondering if there is a way to place that file somewhere globally so the settings are applied to all my projects. Something similar to how the global settings.json works for user settings.
In other words I am looking for a way to avoid having to copy \.vscode\launch.json to every folder I store and write python code in.
Yes, it is possible - you need to put the requisite launch config directly in your user settings file, as described here.
From the linked page:
... currently it is not possible to have one global launch.json file which would be used everywhere, but what works is to add a "launch" object inside your user settings (preferences > user settings). This way it will be shared across all your workspaces
Example:
"launch": {
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${file}",
"cwd": "${workspaceRoot}",
"runtimeExecutable": "/usr/local/bin/node"
}
]
}

Easy check what keybindings are used in Sublime Text editor? [duplicate]

My default key-bindings for pasting are
{ "keys": ["ctrl+v"], "command": "paste" },
{ "keys": ["ctrl+shift+v"], "command": "paste_and_indent" },
I overrode them in my user key-bindings with
{ "keys": ["alt+k"], "command": "paste" },
{ "keys": ["ctrl+k"], "command": "paste_and_indent" },
I use Dvorak keyboard, which means your V is my K. Also, I want paste_and_indent to be the default.
But Ctrl+k executes paste, not paste_and_indent. I determined this by turning on command logging in the console, with
sublime.log_commands(True)
However, if I make the paste_and_indent command to something else, like Ctrl+Alt+k or Alt+k, it correctly calls paste_and_indent.
I looked through the key-bindings for all of my installed packages, and don't see any other command using Ctrl+k. I also disabled most of my packages except syntaxes. I even accidentally disabled Package Control, but still, Ctrl+k only executes paste.
How can I determine and fix this conflict, so Ctrl+k executes paste_and_indent?
Check out the FindKeyConflicts plugin. There are several options for looking at all key bindings, or just conflicting ones, in a variety of contexts. All the options are available via the Command Palette.

Sublime Text 3 usage keymap user

How to embed current file path in a custom user keymap? I'm referring to this documentation:
http://sublimetext.info/docs/en/reference/build_systems.html
Which has been deprecated but I do not see equivalent documentation for $file_path variable which I need to use in my keymap in the latest documentation. I'm not having any luck. My keymap looks like this (trying to launch Google Chrome with flag to package my application):
{
"keys": [
"shift+ctrl+g"
],
"command": "exec",
"args": {
"cmd": [
"c:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
"--pack-extension=${file_path}"
]
}
}
The official documentation is here: https://www.sublimetext.com/docs/3/build_systems.html
You may toggle the version switch in the bottom of the sidebar. The $file_path variable still exists though, so it probably should work. You may try removing the wrapping braces { and }

How to split window at sublime2 at the vintage mode on Mac

I want to split window in sublime text editor.
{
"keys": ["sp"],
# I don't know how to call split window command. Please help!
"command": "split_window_horizontaly",
"context": [
{"key": "setting.command_mode","operand": false},
{"key": "setting.is_widget","operand": false}
]
},
Do you have any idea? Thanks in advance.
So the keys are a list of keys. So for the above key combination you would want something like ["s", "p"]. To manually do the splits, you would have to call the set_layout command with the appropriate arguments. You can see the commands that run when you use the menu by opening the console and entering sublime.log_commands(True).
With that being said, doing it yourself can be more trouble than it's worth. Take a look at the Origami plugin and the Vintage-Origami plugin. The Origami plugin gives some better pane management commands. The Vintage-Origami plugin creates keybindings that can be used in vintage mode. If you don't like those bindings, you can use it as a guide to create bindings that you do like.
Hope that helps.