Visual studio code 如何更改vscode json文件中的预定义变量
例如: 当我运行tasks.json时:Visual studio code 如何更改vscode json文件中的预定义变量,visual-studio-code,vscode-settings,Visual Studio Code,Vscode Settings,例如: 当我运行tasks.json时: { "tasks": [ { "label": "echo", "type": "shell", "command": "echo ${workspaceFolder}\\bulid\\${relativeFileDirname}\\${fileBasename
{
"tasks": [
{
"label": "echo",
"type": "shell",
"command": "echo ${workspaceFolder}\\bulid\\${relativeFileDirname}\\${fileBasenameNoExtension}.exe"
}
],
"version": "2.0.0"
}
它打印
C:\Users\***\OneDrive\***\CLion\bulid\CourseBook\0201_SqList\SqList-main.exe
因为我的文件名是SqList main.c
但是我想要的是Sqlist.exe。
我能做点什么让它打印出来吗
C:\Users\***\OneDrive\***\CLion\bulid\CourseBook\0201_SqList\SqList.exe
我想要一个智能或自动的方法,因为我有很多文件要更改
提示:由于某些原因,.c文件无法重命名。使用扩展名v1.6.0,有一个命令可以转换许多变量
对于这种情况,您必须修改task.json
{
"version": "2.0.0",
"tasks": [
{
"label": "echo",
"type": "shell",
"command": "echo ${workspaceFolder}\\build\\${relativeFileDirname}\\${input:noMain}.exe"
}
],
"inputs": [
{
"id": "noMain",
"type": "command",
"command": "extension.commandvariable.transform",
"args": {
"text": "${fileBasenameNoExtension}",
"find": "-main"
}
}
]
}
您可以使用任何正则表达式作为
find
,并使用捕获组引用($1
)定义一个replace
字符串,以及用于构造正则表达式的标志。您的其他文件名是什么,需要删除什么