Launching Sublime Text 2 in windows command line shortcode
Launch Sublime Text 2 in command line by typing "subl".
So I was trying to set up and follow a tutorial about Ruby on Rails, like most developer tutorials I find, are based on a Mac system. I personally love using a Windows based system for developing.
For this tutorial I needed to run ruby command line and install Sublime Text 2, which is a great little code editor if you haven't tried it yet. But I wanted a simple way to launch Sublime from the command line. Many tutorials suggested creating a doskey and launch an autoexec batch file on launch. That seemed overly complicated. Here is how you do it in a much simpler way.
Step 1: Right click the "My Computer" icon on your desktop, or start up menu and click the properties tab.
Step 2: Click the advanced tab and then click the Environment Variables tab (should be at the bottom of the advanced page)
Step 3: Under system variables click "New" Add the variable name: "SUBLIME_HOME" and value of "C:\Program Files\Sublime Text 2\" (please note this could vary depending on your install location) Then click "Okay"
Step 4: Find the "Path" variable under the system variables, most likely you already have something in the "Path" value. You can click edit and add "%SUBLIMETEXT%" without the "", if you have something already in the "Path" just add a ";" before adding so it should look like this: "C:\whatever;%SUBLIMETEXT%"
Step 5: restart the command line, and type "sublime", this will launch the Sublime Text 2 editor.
Pro tip: if you want to shorten the sublime command you can rename your sublime.exe to subl.exe, restart command line and type "subl" this will now launch the text editor.
All commands should be added without the "".
Thanks for reading.
Written by Rob Cullen
Related protips
12 Responses
Tried the above procedure but still it says : sublime / sublime_text is not recognized .. please suggest!
The reason the guide does not work is because step three creates %SUBLIMEHOME% and step 4 calls %SUBLIMETEXT%. If you created a system variable named %SUBLIMEHOME% referencing your Sublime Text 2 install directory, then add %SUBLIME_HOME% to your %PATH% variable.
You can also use the mklink command to create a symbolic link instead of renaming the sublimetext executable (i.e. "mklink subl.exe sublime_text.exe")
I dont think we need step 3, just simply copy folder of Sublime (C:\Program Files\Sublime Text 2) and add into path environment. Then using Command Line with Administrator permission going to Sublime folder and run command "mklink subl.exe sublime_text.exe". Since thene, just need to open cmd and run subl, Sublime Text will be opened. These steps work perfectly for me
@bnlucas: Many, many thanks! I was really confused by that step and thought it was just my ignorance that made it make no sense. :D I feel like one of the cool kids who can simply type subl
on the CLI now.
Ninomax got it right. Following his directions worked for me. This article's directions did not. That being said, without this article, I would have never found ninomax's comment. It seems I'm at an impasse.
so easy and it working. thankz :)
After i tried many times, It works this way:
New variable:
Variable Name -> SUBLIMEHOME
Variable Value -> C:\Program Files\Sublime Text 3\
The variable value changes depends on your installation dir.
then in the Path variable just add:
;%SUBLIMEHOME%
Including the ; and the %
Good luck and thanks for the helpfull tutorial (Y)
where is that path enviroment folder (it's no work for me i spent all day on this site :)
on windows 8 simply add C:\Program Files\Sublime Text 2\ to your path , then change the name of the .exe file to sublime.exe if different. Now open cmd and run 'sublime' and voila.
Extremely more simple:
1) open the prompt;
2) copy and paste it: set PATH=%PATH%;C:\Program Files\Sublime Text 3
OBS: if the location of installation of sublime is other, change it;
3) restart the prompt and type: subl nameofyour_file.txt
This is it!
you should append "%SUBLIMEHOME%" after Path, if you add a system variable named as SUBLIMEHOME. otherwise system can't find the correct path.
that's really misunderstanding!