命令行subl_使用Subl.exe从命令行打开Sublime文本(Windows)

命令行subl

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.

Sublime Text 3最近更新到了Build3065。如果您不是最新的开发版本 ,您不会经常看到更新。 但是,当它们发生时,更新中总会有一些有趣的东西。

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!

在此最新更新中,有两点引人注意。 一种是在我们文件旁边的侧栏中很酷的图标,另一种是针对Windows用户的。 Windows用户现在在subl.exe具有命令行帮助subl.exe

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

Mac用户已经有很长时间了( subl ),很subl看到Windows出现了这种情况。

什么是Sublime命令行助手? (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.

对于不知道它是什么以及为什么如此之大的那些人,让我们谈谈当前我们如何向Sublime添加文件和文件夹。

The options that were available were to:

可用的选项包括:

  • Drag and drop a file/folder into Sublime

    将文件/文件夹拖放到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!

现在有了命令行帮助器,我们可以直接从命令行向Sublime添加文件/文件夹

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:

让我们看一下如何设置所有内容。 继续并更新Sublime Text,以确保您具有最新的Build 3065( 帮助 -> 检查更新 )。 更新之后,您可以进入命令行并键入:

subl.exe

subl.exe

This should open up Sublime Text.

这应该打开Sublime Text。

subl-not-found

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:

找不到该命令,因为Sublime Text不在您的PATH中。 您可以通过命令行访问Windows PATH中的内容,因此我们需要继续进行添加。 我们将需要进入我们的环境变量设置。 为此,请执行以下操作:

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.

一个不错的捷径是打开命令行并输入sysdm.cpl 。 这将打开我们需要的窗口。

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

创建一个新的系统变量创建一个名为SUBLIME的新系统变量,该变量将指向Sublime安装目录。

subl-environment-variable

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

将系统变量添加到PATH中将以下内容添加到PATH变量的末尾: ;%SUBLIME%

subl-windows-system-path

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!

现在,如果您重新启动命令行(我使用的是Git Bash和ConEmu的混合物),那么您应该可以使用subl.exe命令!

subl.exe进入新的Sublime窗口 (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:

现在,您可以在新的Sublime窗口中打开文件或文件夹。 只需找到您想要的那个并输入:

subl.exe file_name or subl.exe folder_name

subl.exe file_namesubl.exe folder_name

subl.exe进入相同的Sublime窗口 (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.

要将文件或文件夹打开到当前的Sublime Text窗口中,只需在您的subl.exe命令中添加--add修饰符即可。

subl.exe file_name --add or subl.exe folder_name --add

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

在每个版本中,Sublime Text都在变得越来越好。 通过添加subl.exe这为Windows用户带来了Mac上早已想要的功能。

For more Sublime Text goodness, check out these articles:

有关Sublime Text的更多信息,请查看以下文章:

Best of Sublime Text 3 The Complete Visual Guide to Sublime Text 3

最佳Sublime Text 3 完整视觉指南Sublime Text 3

Sublime Text logo used in the Featured Image by Ronan Flynn

Ronan Flynn的精选图片中使用了Sublime Text徽标

翻译自: https://scotch.io/tutorials/open-sublime-text-from-the-command-line-using-subl-exe-windows

命令行subl

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值