gpt4 book ai didi

visual-studio-code - Visual Studio Code settings.json 中的自定义变量

转载 作者:行者123 更新时间:2023-12-05 06:37:14 24 4
gpt4 key购买 nike

我的 settings.json 中有以下设置:

{
"python.pythonPath": "/path/to/bin/python3.6",
"python.formatting.yapfPath": "/path/to/bin/yapf",
"code-runner.executorMap": {
"python": "/path/to/bin/python3.6",
}
}

我想要的是这样的:

{
"venvPath": "/path/to/venv",
"python.pythonPath": "${venvPath}/bin/python3.6",
"python.formatting.yapfPath": "${venvPath}/bin/yapf",
"code-runner.executorMap": {
"python": "${python.pythonPath}",
}
}

有什么办法可以实现吗?

最佳答案

不幸的是,目前不支持使用这样的环境变量(参见 here )。同时,我会建议使用 .bat 文件来编写包含所需路径的 settings.json 文件。对于您的示例,您可以执行以下操作:

set venvPath=/path/to/venv
echo {> settings.json
echo "python.pythonPath": "%venvPath%/bin/python3.6",>> settings.json
echo "python.formatting.yapfPath": "%venvPath%/bin/yapf",>>settings.json
echo "code-runner.executorMap": {>> settings.json
echo "python": "${python.pythonPath}",>> settings.json
echo }>> settings.json
echo }>> settings.json

这将创建以下 settings.json 文件

{
"python.pythonPath": "/path/to/venv/bin/python3.6",
"python.formatting.yapfPath": "/path/to/venv/bin/yapf",
"code-runner.executorMap": {
"python": "${python.pythonPath}",
}
}

关于visual-studio-code - Visual Studio Code settings.json 中的自定义变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48038166/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com