Sublime text windows cmd

Command Line Interface

Sublime Text includes a command line tool, subl , to work with files on the command line. This can be used to open files and projects in Sublime Text, as well working as an EDITOR for unix tools, such as git and subversion.

Setup

Some operating systems and installation methods will require a configuration change to make subl available on the PATH .

Windows

On Windows, the command line helper is subl.exe . To use this from the Command Prompt or Powershell, the Sublime Text installation folder needs to be added to the Path environment variable:

Windows 10

Windows 8

Windows 7

To use subl , the Sublime Text bin folder needs to be added to the path. For a typical installation of Sublime Text, this will be located at /Applications/Sublime Text.app/Contents/SharedSupport/bin .

If using Bash, the default before macOS 10.15, the following command will add the bin folder to the PATH environment variable:

If using Zsh, the default starting with macOS 10.15, the following command will add the bin folder to the PATH environment variable:

Linux

If Sublime Text is installed via one of the Linux Package Manager Repositories or a package, a subl symlink will automatically be installed into the /usr/bin/ directory.

If installing from a tarball, the sublime_text executable should be symlinked to subl , with a command such as:

The exact details of the symlink command will depend on the installation location. Most default PATH environment variable values should contain /usr/local/bin , so no further commands should be necessary.

Usage

To see the available flags, run subl —help . The available flags will vary per operating system – the following example is from a Mac.

Configuring as EDITOR

To use Sublime Text as the editor for many commands that prompt for input, set your EDITOR environment variable:

Specifying -w will cause the subl command to not exit until the file is closed.

Читайте также:  Полоса пропускания windows server

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

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:

This should open up Sublime Text.

If you get the error command not found then we’ll need to set some things up.

Adding Sublime to Your PATH

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:

System Properties -> Advanced System Settings -> Advanced -> Environment Variables

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.

Create a New System Variable Create a new system variable called SUBLIME that will point to the folder of your Sublime installation.

Add the System Variable to Your PATH Add the following to the end of your PATH variable: ;%SUBLIME%

Now if you restart your command line (I’m using a mixture of Git Bash and ConEmu), then you should have the subl.exe command at your disposal!

Читайте также:  Clownfish для скайпа windows 10

subl.exe Into New Sublime Window

You now have the ability to open a file or folder in a new Sublime window. Just find the one you want and type:

subl.exe file_name or 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.

subl.exe file_name —add or 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 these articles:

Sublime Text logo used in the Featured Image by Ronan Flynn

How can I open command line prompt from Sublime in windows7

I’v created a function in VIM named OpenCMD(), it used for open command line or terminal in VIM (And cd in the current file path)

Now, I want to open command line and cd in the current file path in Sublime (sublime 3 beta). The function as the same as the OpenCMD() .

I did as the the first guy answered (Create cmd, cmd.py and Context.sublime-menu). But it cannot work, the cmd operation always disabled.

Is there any way can get it? Thanks in advance!

5 Answers 5

Only one step (for me) has to be changed is the file name should be uppercase. Use CMD instead of cmd .

My steps (Win7):

  • Open folder %APPDATA%\Sublime Text 3\Packages or just click Preferences ->Browser Packages.. in sublime-text-3 Beta
  • Create a folder named CMD (Uppercase). The path of CMD should be %APPDATA%\Sublime Text 3\Packages\CMD .
  • Open the folder CMD, and create a file, named cmd.py (lowercase), paste the context as below:
  • Create a file (again), named Context.sublime-menu . Add context as below:
  • The Cmd function will work in context menu (right-click). For example:

Of cause, if you want to open command line by command (by ‘cmd’ for example), you can add the following context into Default (Windows).sublime-keymap file. :

You can open it from Preferences -> Key Bindings — User

Открывать документы через cmd в редакторе Sublime Text 2

Приветствую. Подскажите пожалуйста.

Как правильно прописать в командной строке, что бы все мои редактируемые файлы открывались в редакторе Sublime Text 2

Читайте также:  Чем заменить проигрыватель windows media

Например, при вводе такой строки: $ subl Gemfile

У меня открылся Gemfile в редакторе Sublime Text 2

  • Вопрос задан более трёх лет назад
  • 8931 просмотр

Вот нашел решение для пользователей Windows

doskey subl=»C:\Program Files\Sublime Text 2\sublime_text.exe» $*

Соответственно путь по которому установлена программа у каждого пользователя свой.

Создаем симлинк /usr/local/bin/sublime ведущий на /Applications/Sublime Text.app/Contents/SharedSupport/bin/subl

Это для Mac. Под остальные ОС по аналогии.

Если интересует запуск по собственным алиасам, то можно поставить специальные лаучеры для этого — например launchy, enso и подобные.

Возник такой же вопрос, нашел такой ответ:
1. Add the Sublime directory to the windows PATH
2. I think ‘subl’ is a Mac-only command. For Windows it’s ‘sublime_text’

[How to run code by using cmd from sublime text 3 ]

I am a newbie in Python, and have a problem. When I code Python using Sublime Text 3 and run directly on it, it does not find some Python library which I already imported. I Googled this problem and found out Sublime Text is just a Text Editor.

I already had code in Sublime Text 3 file, how can I run it without this error?

For example:

‘ModuleNotFoundError: No module named ‘matplotlib’.

I think it should be run by cmd but I don’t know how.

3 Answers 3

Depending on what OS you are using this is easy. On Windows you can press win + r, then type cmd . This will open up a command prompt. Then, type in pip install matplotlib . This will make sure that your module is installed. Then, navigate to the folder which your code is located in. You can do this by typing in cd Documents if you first need to get to your documents and then for each subsequent folder.

Then, try typing in python and hitting enter. If a python shell opens up then type quit() and then type python filename.py and it will run.

If no python shell opens up then you need to change your environment variables. Press the windows key and pause break at the same time, then click on Advanced system settings. Then press Environment Variables. Then double click on Path. Then press New. Then locate the installation folder of you Python install, which may be in C:\Users\YOURUSERNAME\AppData\Local\Programs\Python\Python36 Now put in the path and press ok. You should now be able to run python from your command line.

Оцените статью