我想知道是否可以(使用内置变量)直接使用从集成终端在Visual Studio中打开的当前文件,例如:
>some_command $current_file (Where $current_file would be a built-in variable that calls the current active file)
如果终端是CMD(DOS),而不是我现在要做的事情:
> more C:\The\Path\to\File\MyFile.txt
或者如果使用的终端是bash:
$ cat /The/Path/to/File/MyFile.txt
作为一种解决方法,您可以使用新功能将${file}
等变量发送到具有此类键绑定的终端:
{
"key": "ctrl+shift+t",
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "'${file}'\u000D" }
}
然后,在终端类型some_command
中按Ctrl-Shift-T,将附加当前文件名并运行命令。
\u000D
是一个回归。