【问题标题】:How can I open Sublime Text 2 files from the command line in linux to a tab, not a new window如何从 linux 中的命令行将 Sublime Text 2 文件打开到选项卡,而不是新窗口
【发布时间】:2012-08-26 20:03:38
【问题描述】:

我有 ST2 设置,因此我可以执行“sublime file.txt”,它将在 ST2 窗口中打开。但是如何让它在当前打开的窗口中的新标签页中打开呢?

【问题讨论】:

  • 在我的安装中,它会在新选项卡中打开文件。你是如何安装 SublimeText2 的?
  • 我将 tarball 提取移到 /usr/lib/ 并使用以下符号链接到它: sudo ln -s /usr/lib/Sublime\ Text\ 2/sublime_text /usr/bin/sublime

标签: linux ubuntu sublimetext2


【解决方案1】:

试试 Sublime 命令行帮助

subl --help Sublime Text 2 Build 2217

Usage: subl [arguments] [files]         edit the given files
   or: subl [arguments] [directories]   open the given directories
   or: subl [arguments] -               edit stdin

Arguments:
  --project <project>: Load the given project
  --command <command>: Run the given command
  -n or --new-window:  Open a new window
  -a or --add:         Add folders to the current window
  -w or --wait:        Wait for the files to be closed before returning
  -b or --background:  Don't activate the application
  -s or --stay:        Keep the application activated after closing the file
  -h or --help:        Show help (this message) and exit
  -v or --version:     Show version and exit

--wait is implied if reading from stdin. Use --stay to not switch back
to the terminal when a file is closed (only relevant if waiting for a file).

Filenames may be given a :line or :line:column suffix to open at a specific
location.

在您打开一个新窗口后,应按照默认行为将后续文件添加到那里。

【讨论】:

  • 根据this userecho 和我自己对同一版本的经验,将stdin 指定为文件只是OS X 的一个选项。
  • 我不确定我是否理解这个问题与编辑标准输入有什么关系?
  • 道歉 Mikko,早些时候我在寻找有关我的构建为什么没有标准输入选项的信息。发现后,我又浏览了一堆搜索结果标签,试图留下有用的信息。不应该在这里留下任何东西:)
  • 使用 --new-window --wait 非常适合我使用 Sublime Text 2 作为 Mercurial 的默认文本编辑器。
  • 这也是我的 EDITOR 技巧,以便 Git 使用 Sublime 提交消息:github.com/miohtama/ztanesh/blob/master/zsh-scripts/rc/…github.com/miohtama/ztanesh/blob/master/zsh-scripts/bin/…
【解决方案2】:

这适用于 Ubuntu 12.04:

subl filename

subl -n filename(如果您希望它在单独的窗口中打开)

【讨论】:

    【解决方案3】:
    subl fileName
    

    如果你想打开一个新文件,请使用

    subl -n new_file_name
    

    【讨论】:

    【解决方案4】:

    另一种选择是: 打开文件。

    [sublime index.html script.js styles.css]
    

    打开一个文件夹 [sublime folderName]

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-15
      • 2016-10-12
      • 2013-06-23
      • 1970-01-01
      • 2018-05-25
      • 2012-07-06
      • 2012-01-28
      相关资源
      最近更新 更多