I have ST2 setup so that I can do 'sublime file.txt' and it will open in a ST2 window. But how can I make it open in a new tab in the currently open window?
Asked
Active
Viewed 5.1k times
43
-
1In my installation it opens the file in a new tab. How did you install SublimeText2? – Geordee Naliyath Sep 01 '12 at 05:38
-
1I moved the tarball extraction to /usr/lib/ made symlink to it with: sudo ln -s /usr/lib/Sublime\ Text\ 2/sublime_text /usr/bin/sublime – phirschybar Sep 01 '12 at 21:59
4 Answers
54
Try Sublime command line help
subl --help Sublime Text 2 Build 2217
Usage: subl [arguments] [files] edit the given files
or: subl [arguments] [directories] open the given directories
or: subl [arguments] - edit stdin
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
-s or --stay: Keep the application activated after closing the file
-h or --help: Show help (this message) and exit
-v or --version: Show version and exit
--wait is implied if reading from stdin. Use --stay to not switch back
to the terminal when a file is closed (only relevant if waiting for a file).
Filenames may be given a :line or :line:column suffix to open at a specific
location.
After you have opened a new window the subsequent files should be added there as per the default behavior.

Mikko Ohtamaa
- 82,057
- 50
- 264
- 435
-
According to [this userecho](http://sublimetext.userecho.com/topic/87972-allow-editing-stdin-on-linux/) and my own experience with that same build, specifying `stdin` as a file is only an option with OS X. – Ben Graham Nov 20 '12 at 01:34
-
I am not sure if I understand how this question is related of editing stdin? – Mikko Ohtamaa Nov 20 '12 at 02:00
-
Apologies Mikko, earlier I was looking for information about why my build didn't have the stdin option. After finding out I went back through my stack of search result tabs, trying to leave helpful information. Shouldn't have left anything here :) – Ben Graham Nov 20 '12 at 02:48
-
1Using --new-window --wait worked perfectly for me to use Sublime Text 2 as my default text editor for Mercurial. – T.W.R. Cole Jan 23 '13 at 16:47
-
Also here is my EDITOR trick so that Git uses Sublime for commit messages: https://github.com/miohtama/ztanesh/blob/master/zsh-scripts/rc/39-osx-vars and https://github.com/miohtama/ztanesh/blob/master/zsh-scripts/bin/subl-wrapper – Mikko Ohtamaa Jan 23 '13 at 22:33
-
If it's opening in a new window by default, you probably have the wrong dbus address in your local terminal session. This can happen if you're using tmux. export DBUS_SESSION_BUS_ADDRESS in your tmux terminal, set it to the value you get in a new local terminal window. – ACyclic May 08 '13 at 13:45
6
subl fileName
and if you want to open a new file use
subl -n new_file_name

Arun Kasyakar
- 905
- 8
- 9
-
1
-
This appears to be just a repeat of [this existing answer](https://stackoverflow.com/a/16207695). – Pang Nov 16 '18 at 00:44
2
another option is: to open file.
[sublime index.html script.js styles.css]
to open a folder [ sublime folderName ]

Robert
- 5,278
- 43
- 65
- 115

Zabe Sangary
- 61
- 4