如何在MacVim中使用终端打开一个新文件并将其显示在一个选项卡中,而不是在一个新窗口中?

5

我把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 )时,才会在新标签页中打开新文件。

1个回答

7

这个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

1
完美。它正好做我想做的事情。谢谢! - hobbes3

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接