Evhz
Evhz

Reputation: 9248

Open sublime text file at a line number using command line

I'm trying to open a file using sublime text 3, and I would like to open it with the cursor at a concrete line number.

I've been checking subl --help but I could find no option for a concrete line. Therefore I'm just using: subl filename

Is there any option to do it?

Upvotes: 8

Views: 3287

Answers (1)

Xavier Guihot
Xavier Guihot

Reputation: 61666

You can use :line to open at the given line:

subl file.txt:345

In my version of sublime-text 3, subl --help does give me the indication (last line):

subl --help
Sublime Text build 3143

Usage: sublime_text [arguments] [files]         edit the given files
   or: sublime_text [arguments] [directories]   open the given directories

Arguments:
  --project <project>: Load the given project
  --command <command>: Run the given command
  -n or --new-window:  Open a new window
  -a or --add:         Add folders to the current window
  -w or --wait:        Wait for the files to be closed before returning
  -b or --background:  Don't activate the application
  -h or --help:        Show help (this message) and exit
  -v or --version:     Show version and exit

Filenames may be given a :line or :line:column suffix to open at a specific location.

Upvotes: 18

Related Questions