【问题标题】:How do I open a new file from Terminal to a tab instead of a new window on MacVim?如何在 MacVim 上将新文件从终端打开到选项卡而不是新窗口?
【发布时间】:2014-04-30 16:24:42
【问题描述】:

我将mvim 移动到/usr/local/bin,所以如果我在终端输入mvim file.html,MacVim 将在新窗口中打开并打开文件file.html

但是如果我从终端打开另一个文件,那么它将打开 另一个 MacVim 窗口。

是否可以在 MacVim 上将新文件作为新标签打开?

我目前的 MacVim 设置为

Open files from application: in the current window
    with a tab for each file

但只有当我从 MacVim 打开文件(不从终端运行mvim)时,才会在新选项卡中打开新文件。

【问题讨论】:

    标签: vim macvim


    【解决方案1】:

    This hack 应该可以工作,但每次更新 MacVim 时维护可能会令人沮丧。它要求您编辑 mvim 脚本。这似乎是一个长期存在的已知问题。

    mvim `which mvim`
    
    ## Add the following line to the top of the file, below the commented section:
    
    tabs=true
    
    ## Replace the `if` structure at the bottom of the file with the following:
    
    # Last step:  fire up vim.
    if [ "$gui" ]; then
      if $tabs && [[ `$binary --serverlist` = "VIM" ]]; then
        exec "$binary" -g $opts --remote-tab-silent ${1:+"$@"}
      else
        exec "$binary" -g $opts ${1:+"$@"}
      fi
    else
      exec "$binary" $opts ${1:+"$@"}
    fi
    

    【讨论】:

    • 完美。它做了我想做的事。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2012-01-28
    • 2011-06-21
    • 2012-07-06
    • 2019-03-04
    • 2011-10-29
    相关资源
    最近更新 更多