我正在尝试摆脱WebStorm并尝试配置VS Code以获得WebStorm. 我正在尝试File Watcher在 VS Code 中实现功能。我曾经在 WebStorm 中有 Jade 和 Stylus 的文件观察器。我已经为他们准备了 gulp 任务,并且也添加了它们tasks.json。我什至也为他们提供了键绑定。但我必须手动运行它们。我想要的是,无论何时保存文件,它都会检查它是Jade文件还是Stylus文件,然后运行相应的任务以生成 HTML 或 CSS 文件。
是否可以在 VS Code 中做到这一点?如果是,那么我该怎么做?
当尝试在 vscode 中启动调试会话时,它会引发关于未找到指定任务的错误。我已经尝试过类似这样的其他 SO 问题的解决方案,但没有成功。
启动.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
...
},
{
"name": "MSEventHubs_Audit",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/audit-events.py",
"console": "integratedTerminal",
"args": [
"config/config.ini",
],
"envFile": "${workspaceFolder}/.env",
"env": {"PYTHONPATH": "${workspaceRoot}"},
"justMyCode": false,
"preLaunchTask": {
"task": "audit_tunnel"
}
},
{
...
},
]
}
Run Code Online (Sandbox Code Playgroud)
任务.json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the …Run Code Online (Sandbox Code Playgroud) 我试图弄清楚如何在 Visual Studio Code 中进行自定义运行配置,但没有成功找到任何描述我的用例的文档。
我想创建一个运行配置来运行我可以设置来运行我的代码的任意命令。这是必要的,因为我使用的语言没有提供运行配置的扩展。
我确实发现这对于任务是可能的,但我无法弄清楚如何通过按 F5 来运行任务(就像使用运行配置一样)。
所以,这就是我想要做的:定义当我按 F5 时将运行命令(run.exe ${当前选择的 VSCode 文件})的内容。
任务完成后,终端将保持打开状态。有没有办法自动隐藏它?
我不是在谈论关闭窗口,如https://code.visualstudio.com/updates/v1_57#_automatically-close-task-terminals中所述,因为这将删除所有输出。
我只想隐藏终端,以便在需要时仍然可以通过打开终端面板返回到输出。
扫描文档可以发现:
{
"key": "f4",
"command": "workbench.action.tasks.runTask"
}
Run Code Online (Sandbox Code Playgroud)
但它只打开任务面板并提示选择任务。问题是我如何运行特定任务?
{
"key": "f4",
"command": "workbench.action.tasks.runTask.customTask"
}
//Command not found
Run Code Online (Sandbox Code Playgroud) 我尝试在task.json中放置一个用于打字稿类型task的路径:
{
"version": "2.0.0",
"tasks": [
{
"identifier": "tsc-client",
"label": "tsc-client",
"type": "typescript",
"tsconfig": "src/client/tsconfig.json",
"problemMatcher": [
"$tsc"
]
},
{
"identifier": "tsc-server",
"label": "tsc-server",
"type": "typescript",
"tsconfig": "src/server/tsconfig.json",
"problemMatcher": [
"$tsc"
]
},
{
"identifier": "build-all",
"label": "build-all",
"dependsOn": ["tsc-client", "tsc-server"]
}
]
}
Run Code Online (Sandbox Code Playgroud)
然后在我的launch.json中,我有:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"preLaunchTask": "tsc-client",
"name": "Launch Program",
"program": "${workspaceFolder}/server/server-repsic.js"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我大声说,我得到:
Error: The typescript task detection didn't contribute a task for the following configuration: …Run Code Online (Sandbox Code Playgroud) 对于 dotnet 有dotnet watch run
对于节点有nodemon
无论如何,在开发 azure 函数时要注意文件更改吗?到目前为止,我必须func start在每次更改后进行测试。我没有看到任何与此相关的信息。
c# visual-studio-code azure-functions vscode-tasks azure-functions-core-tools
我正在为 vscode 设置一个“cppcheck”任务。它有效,但问题匹配器无法捕获问题。
我尝试过“$gcc”问题匹配器以及一些自定义配置。
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "cppcheck",
"type": "shell",
"command": "cppcheck --template=gcc --enable=style --project=${workspaceFolder}/build/compile_commands.json",
"problemMatcher": "$gcc",
}
]
}
Run Code Online (Sandbox Code Playgroud)
或这个:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "cppcheck",
"type": "shell",
"command": "cppcheck --template=gcc --enable=warning src/jc_certreq.cpp",
"problemMatcher": {
"owner": "cpp",
"fileLocation": "absolute",
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4, …Run Code Online (Sandbox Code Playgroud) 我正在尝试定义一个 VSCode 任务tasks.json,以适应 VSCode 运行的特定架构。为此,我想将架构设为uname --m(例如“aarch64”或“amd64”)。我的目标是将 的输出uname插入到这样的环境变量中
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "cmake",
"args": [
"-DMYLIB_INCLUDE_DIR=$MYLIB/include",
"-DMYLIB_LIBRARY=$MYLIB/lib"
],
"options": {
"env": {
"MYLIB": "${workspaceFolder}/mylib/${command:get_arch}"
}
},
}
]
Run Code Online (Sandbox Code Playgroud)
就我而言,我将有架构的特定版本mylib下mylib/aarch64,mylib/amd64,等。
到目前为止,我尝试定义get_arch在 的环境定义中使用的第二个任务MYLIB,它只是运行uname。
{
"label": "get_arch",
"type": "shell",
"command": "uname --m"
}
Run Code Online (Sandbox Code Playgroud)
当然,这个任务不是一个正确的命令,所以它没有被 VSCode 检测到,我的构建任务失败了。我查看了有关变量替换的文档,但他们没有提到是否可以替换shell 命令。我想这在扩展中是可能的,但我想让事情尽可能简单。
VSCode 去年添加了一项功能,可以在“打开文件夹时”自动运行任务。但是在使用工作区时“打开文件夹”是什么意思?
具体来说,如果你打开一个工作区,"runOn": "folderOpen"任务会运行吗?如果是这样,如何?
我之所以这么问是因为我将任务配置为自动运行,但是当我打开工作区时它没有运行。(任务在手动触发时正确运行。)
我正在同时尝试许多小项目,并在根文件夹上打开一个 VS Code 窗口。
它们可以是 JS 项目或 Python 项目,或其他可通过终端命令运行的项目。
我想创建一个 VS Code任务:
1) 在当前打开并聚焦的文件上启动程序;
2) 将当前工作目录设置为该文件的目录。
这必须动态发生,即我不想每次想要启动不同的文件时都手动设置当前文件和当前工作目录。
我怎样才能做到这一点?
我试图使用键盘快捷键来创建一个以日期时间为前缀以及我输入的一些附加文本的新文件。
我知道有一个生成新文件的快捷方式,并且我已经看到了用于将日期时间插入编辑器的片段和扩展名,但这些扩展名似乎在新文件名对话框中不起作用。
谢谢!
我试图从工作区中运行一个.cpp文件,但是给了我关于不添加c ++ 11 / higher标志的错误,但是我将它们添加到task.json中
错误
[Running] cd "c:\Users\Nuhash\Desktop\test\" && g++ main.cpp -o main && "c:\Users\Nuhash\Desktop\test\"main
main.cpp:8:1: error: expected unqualified-id before 'using'
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
^
main.cpp:10:1: error: expected unqualified-id before 'using'
using ordered_set_rev = tree<T, null_type, greater<T>, rb_tree_tag, tree_order_statistics_node_update>;
^
main.cpp:12:1: error: expected unqualified-id before 'using'
using dijkstra = priority_queue<T, vector<T>, greater<T>>;
^
main.cpp:62:31: warning: variadic templates only available with -std=c++11 or -std=gnu++11
template <typename T, typename... Args>
^
main.cpp:63:52: warning: variadic templates only …Run Code Online (Sandbox Code Playgroud) vscode-tasks ×13
c# ×1
c++ ×1
cppcheck ×1
file-watcher ×1
gulp ×1
json ×1
tsc ×1
typescript ×1