如何使用VS Code从提示符打开文件并转到特定的行号?

Red*_*ter 6 command-line editor visual-studio-code

我想将Visual Studio Code与我的一些其他工具集成,其中一部分是能够启动Visual Studio Code传递文件名,行号和列号,以将光标定位在文件中的特定位置.

有没有办法做到这一点?

Ben*_*ero 5

使用新的0.5.0版本,您可以使用以下语法在行和列上打开一个或多个文件:

code -g file1:<line>:<column?> file2:<line>:<column?> file3:<line>:<column?>
Run Code Online (Sandbox Code Playgroud)

  • 在使用代码v1.5.3的Windows 10中,我收到以下错误:`` - goto'模式中的参数应该采用'FILE(:LINE(:COLUMN))'的格式,当我执行`code -gc时:\TMP \new.txt:1:1`.该文件存在.进一步测试,我发现`code c:\ tmp \new.txt:1:1`会打开一个`Untitled-1`文件.`code c:\ tmp \new.txt`正确打开文件.我究竟做错了什么? (2认同)