S Grey
S Grey

Reputation: 649

Open file at specific line in VSCode

In this section: https://code.visualstudio.com/docs/editor/codebasics#_additional-command-line-arguments

It states you can use --goto to open a file at a specific line. I grep code with AstroGrep and every time I try to use the --goto argument VsCode fails to open.

An example argument i'm using which fails:

Code.exe --goto C:\filepath\filename.txt:450:11

or

Code.exe --goto "C:\file path\filename.txt":450:11

What is wrong with this file:line:column syntax? or is this a bug in vscode?

Thanks

Upvotes: 33

Views: 14879

Answers (3)

ndnam198
ndnam198

Reputation: 84

In MacOS, I achieve the same thing by running

// `code` should be added to PATH beforehand
code --goto "<filepath>:<linenumber>:<x-coordinates>"

Upvotes: 1

Kevin
Kevin

Reputation: 231

Code.exe --goto "C:\file path\filename.txt:450:11" 

worked for me, take a closer look on the quotation marks.

Upvotes: 23

DAXaholic
DAXaholic

Reputation: 35358

Seems to be a known issue which was fixed a couple of days ago - see here

Workaround until next version:

  • Use relative paths
  • Use insider version of VSCode

Upvotes: 8

Related Questions