我的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}",
}
}
有没有办法实现这个目标?
答案 0 :(得分:0)
不幸的是,现在不支持使用像这样的环境变量(参见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}",
}
}