Tutorial

Open Sublime Text From the Command Line Using Subl.exe (Windows)

Draft updated on Invalid Date
    Default avatar

    By Chris on Code

    Open Sublime Text From the Command Line Using Subl.exe (Windows)

    This tutorial is out of date and no longer maintained.

    Introduction

    Sublime Text 3 was recently updated to Build 3065. If you’re not on the bleeding edge dev builds, you won’t see updates too often. When they happen, though, there’s always some fun stuff in the update.

    In this latest update, two things stood out. One is having cool icons in the sidebar next to our files, and the other is geared towards Windows users. Windows users now have a command-line helper in subl.exe!

    Mac users have had this for a long time (subl) and it’s great to see the equivalent come to Windows.

    What is the Sublime Command Line Helper?

    For those of you that don’t know what it is and why it’s so great, let’s talk about how we currently add files and folders to Sublime.

    The options that were available were to:

    • Drag and drop a file/folder into Sublime
    • Use the Open commands in the menu

    Now with the command line helper, we can add files/folders to Sublime straight from the command line!

    Let’s take a look at how we can get everything set up. Go ahead and update Sublime Text to make sure you have the latest Build 3065 (Help -> Check for Updates). After the update, you may be able to go into your command line and type:

    1. subl.exe
    2. ```
    3. This should open up Sublime Text.
    4. If you get the error **command not found** then we'll need to set some things up.
    5. Adding Sublime to Your PATH
    6. ---------------------------
    7. The command wasn't found because Sublime Text isn't in your PATH. The things in your Windows PATH are accessible via the command line so we'll need to go ahead and add it. We will need to go into our **Environment Variables** settings. Do this by going to:
    8. **System Properties** -> **Advanced System Settings** -> **Advanced** -> **Environment Variables**
    9. A nice shortcut to do this is to open up your command line and typing `sysdm.cpl`. That will open up the window we need.
    10. **Create a New System Variable** Create a new system variable called `SUBLIME` that will point to the folder of your Sublime installation.
    11. **Add the System Variable to Your PATH** Add the following to the end of your PATH variable: `;%SUBLIME%`
    12. Now if you restart your command line (I'm using a mixture of [Git Bash and ConEmu](https://www.digitalocean.com/community/tutorials/get-a-functional-and-sleek-console-in-windows)), then you should have the `subl.exe` command at your disposal!
    13. subl.exe Into New Sublime Window
    14. --------------------------------
    15. You now have the ability to open a file or folder in a **new Sublime window**. Just find the one you want and type:
    16. ```command
    17. subl.exe file_name
    18. ```
    19. Or:
    20. ```command
    21. subl.exe folder_name

    subl.exe Into Same Sublime Window

    To open files or folders into the current Sublime Text window, just add the --add modifier to your subl.exe command.

    1. subl.exe file_name --add

    Or:

    1. subl.exe folder_name --add

    Conclusion

    With every version, Sublime Text just keeps getting better and better. With the addition of subl.exe this brings a long wanted feature that was on Mac to the Windows users.

    For more Sublime Text goodness, check out this article:

    Best of Sublime Text 3

    Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

    Learn more about us


    About the authors
    Default avatar
    Chris on Code

    author

    Still looking for an answer?

    Ask a questionSearch for more help

    Was this helpful?
     
    Leave a comment
    

    This textbox defaults to using Markdown to format your answer.

    You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

    Try DigitalOcean for free

    Click below to sign up and get $200 of credit to try our products over 60 days!

    Sign up

    Join the Tech Talk
    Success! Thank you! Please check your email for further details.

    Please complete your information!

    Get our biweekly newsletter

    Sign up for Infrastructure as a Newsletter.

    Hollie's Hub for Good

    Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

    Become a contributor

    Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

    Welcome to the developer cloud

    DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

    Learn more
    DigitalOcean Cloud Control Panel