我安装了Sublime Text,想知道如何从终端打开其中的rb文件。我看到让Sublime Text成为我的核心编辑器的命令是什么?我看到我可以让Sublime成为我的核心编辑器,但我想要能够打字

sublime file.rb

在Windows中如何做到这一点?


当前回答

Windows ONLY:如何在窗口中打开“Sublime Text”?

假设你的Sublime Text 3位于“C:\Program Files\Sublime Text 3”目录中

在Git Bash中复制粘贴并运行: echo 'alias subl="/C/Program\ Files/Sublime\ Text\ 3/sublime_text.exe"' >> ~/.bashrc .exe 关闭Git Bash并重新打开它。 在Git bash类型中: subl

其他回答

将安装文件夹添加到windows路径下。


- Click on windows button 
- Type advance system settings in search box
- Click on the result (View Advance System Setting)
- Click on the Environment Variable Button at the Bottom right
- Go to System Variable Section Second
- Search for Path 
- Click on Path and Click on Edit Button 
- Click on New on right sidebar 
- Copy the Folder Path of Sublime Text Editor Sample(C:\Program Files\Sublime Text 3)
- Paste on New Line on Environment Variable
- Click on OK on Every Dialog Box
- All Set Now Follow below Steps

如果打开,则关闭CMD,或者启动新的CMD。 进入你的项目文件夹。 在Windows文件资源管理器中单击“地址”行。 全选并输入CMD。 它将在CMD中打开项目文件夹。 然后输入subl。//不要忘记添加 在(subl) ex (subl .)后面加点(.) 所有这些都完成了,它将在sublime文本编辑器中打开项目。

创建注册表:

微软HKEY_LOCAL_MACHINE \ SOFTWARE \ \ Windows \ CurrentVersion \ \ sublime.exe应用路径

将默认参数REG_SZ的值更新为:

C:\Program Files\Sublime文本2\sublime_text.exe

    @echo off
    :: File: TextFiles.Starter.DESKTOP-M175NUE.cmd v1.1.0 docs at the end 

    :: this just an iso-8601 wrapper for windows:
    :: src: http://www.cs.tut.fi/~jkorpela/iso8601.html
    call GetNiceTime.cmd

    :: go the run dir
    cd %~dp0z

    :: this is the dir containing the batch file
    set _MyDir=%CD%

    :: look around , set vars
    for %%A in (%0) do set _MyDriveLetter=%%~dA
    for %%A in (%0) do set _MyPath=%%~pA
    for %%A in (%0) do set _MyName=%%~nA
    for %%A in (%0) do set _MyEtxtension=%%~xA

    :: contains absolute file paths of the files to open like this
    set _ListFile=%_MyDir%\%_MyName%.lst
    :: example of lines in the list file - take out the ::space
    :: C:\Users\ysg\Desktop\TextFiles.Starter.DESKTOP-M175NUE.cmd
    :: C:\Users\ysg\Desktop\TextFiles.Starter.DESKTOP-M175NUE.lst


    :: set _Program="C:\Program Files\TextPad 8\TextPad.exe"
    set _Program="C:\Program Files\Sublime Text 3\sublime_text.exe"
    set _
    :: DEBUG PAUSE

    :: sleep 2
    ping -n 2 www.google.com > NUL

    :: for each line of the cat file do open 
    :: for TextPad , obs note the quoting 
    :: for /f "tokens=*" %%i in ('type "%_ListFile%"') do ^
    :: cmd /c "%_Program% "%%i""

    :: for sublime, obs note the quoting 
    for /f "tokens=*" %%i in ('type "%_ListFile%"') do ^
    cmd /c "%_Program% -t "%%i""
    :: DEBUG PAUSE

    :: Purpose: 
    :: to start a list of non-binary files from a list file on Windows 10
    :: Tested on Windows 10, should work on Win7 too
    :: 
    :: Requirements:
    :: TextPad 8 or Sublime
    :: 
    :: 
    :: Usage: 
    :: copy this file onto your Desktop, list the absolute paths in to the list file 
    :: change the program name in the _Program if if you want other editor
    :: 
    :: VersionHistory: 
    :: 1.1.0 --- 2017-10-06 09:42:54 --- ysg --- added sublime 
    :: 1.0.1 --- 2013-04-15 08:19:10 --- ysg --- added - todo-%today%.txt file opening
    :: 1.0.0 --- 2012-05-23 09:08:57 --- ysg -- Initial creation 

这个powershell允许我将管道连接到编辑函数(或以正常方式使用它)

function edit
{
    param( [Parameter(ValueFromPipeline=$true,Position=0)] $file )
    begin { set-alias EDITOR 'W:\tools\sublime_text.bat' }
    process { EDITOR $file }
}

下面是sublime_text.bat,出于某种原因,它似乎是必要的(有人知道为什么吗?)

START "Sublime Text 2" "C:\Program Files\Sublime Text 2\sublime_text.exe" %*

从版本3065(发布日期:2014年8月29日)起,Sublime文本包括一个命令行助手,即eley sub .exe。它位于sublime的安装文件夹中:将其复制到系统路径中包含的文件夹中。 例如,在我的例子中,我复制了它

从C:\Program Files\Sublime文本3

对C:\Windows\System32

然后你可以在你的终端/控制台中使用subl作为命令来打开任何文件,比如在你的例子中:

subl file.rb

或者你也可以修改你的系统PATH变量来包含sublime的安装文件夹,但我相信这要复杂得多。