Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I open a file from a prompt with VS Code and go to a specific line number?

I want to integrate Visual Studio Code with some of my other tools, and part of that is being able to launch Visual Studio Code passing a file name, line number, and column number, to position the cursor at a specific place in the file.

Is there a way to do this?

like image 908
D'Arcy Rittich Avatar asked May 11 '15 14:05

D'Arcy Rittich


People also ask

How do you jump to a specific line in VS Code?

The Go To Line dialog box lets you move to a specific line in the active document. To access this dialog box, open a document for editing, and then select Edit > Go To > Go To Line or press Ctrl+G.

How do you jump to a file in VS Code?

VS Code provides two powerful commands to navigate in and across files with easy-to-use key bindings. Hold Ctrl and press Tab to view a list of all files open in an editor group. To open one of these files, use Tab again to pick the file you want to navigate to, then release Ctrl to open it.

Can you open a file from VS Code terminal?

Launch VS Code. Open the Command Palette (Cmd+Shift+P) and type 'shell command' and press Enter.


1 Answers

With the new 0.5.0 release you can open one ore multiple files on a line and column using the following syntax:

code -g file1:<line>:<column?> file2:<line>:<column?> file3:<line>:<column?>
like image 51
Benjamin Pasero Avatar answered Sep 30 '22 08:09

Benjamin Pasero