使用带有 --remote-silent 的单个 vim 实例
我一直是控制台 vim 用户,但最近我尝试使用 gvim。 我已经进行了一些设置,这样我的控制台习惯就不会受到影响,例如 在当前目录中使用 . 打开 urxvt 终端
然而,用我的上网本打开多个 gvim 和终端是 太可怕了,我的振动空间很快就减少到一两厘米。充其量, 窗口宽度减半,无法垂直分割 屏幕(平铺 wm)。
我通过将 vim 别名为 gvim --remote-silent 来解决这个问题,它 几天工作正常,但今天我需要使用 -c '' 和 意识到在 --remote-silent 后面有任何开关会打开这些 切换为文件。因此,执行 gvim --remote-silent --foo bar
打开两个 文件,--foo 和 bar。
我为 alias vim=gvim
添加了一个新别名,但我担心这会让我成为 再次控制台 vim 用户,比我想象的要早。
所以问题是,继续使用 gvim 的首选方式是什么, 以最小的努力(设置系统可能很费力),这样我就可以 仍然继续使用 vim 的全部功能。该解决方案不需要使用 远程 vim,它应该只是最小化 gvim 窗口。
I've always been a console vim user, but lately I've tried to use gvim.
I've made settings such that my console habits won't suffer, such as
opening an urxvt terminal at the current directory with .
However having multiple gvims and terminals open with my netbook is
horrible, quickly reducing my vim-space to a centimeter or two. At best,
the window width is halved, making it impossible to vertically split
screen (tiling wm).
I went around this problem by aliasing vim to gvim --remote-silent
and it
worked fine for a couple of days, but today I needed to use -c '' and
realized that having any switches behind --remote-silent opens those
switches as files. So doing gvim --remote-silent --foo bar
opens two
files, --foo and bar.
I put a new alias for alias vim=gvim
, but I'm afraid this will make me a
console vim user again, sooner than I thought I would.
So the question is, what would be the preferred way to keep using gvim,
with minimal effort (setting up the system can be laborous) so that I can
still keep using vim with its full power. The solution does not need to use
remote vim, it should just minimize the gvim windows.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我来晚了,但我有一个建议。
首先,我同意@Herbert - 通常没有理由运行多个 Vim 实例(控制台或其他)。将事物保存在一个实例中的好处实在是太大了。但是,我认为需要混合
-c
;虽然我看不出有必要自己做:D。我认为获得此功能的最佳方法是使用 vim 的
--remote-send
功能,而不是--remote-silent
。不过,这意味着需要编写一些 shell 脚本:我只对此进行了少量测试,但您应该能够执行以下操作:
应该编辑
file1< /code> 并移至其底部。然后,它还应该将
file2
、file3
和file4
添加到 args 列表中,以便您可以执行诸如:bnext.当您不提供
-c
时,它还应该恢复为与--remote-silent
相同的功能。我真的认为为了将命令行体验与单个 Vim 实例正确集成,跳过这些障碍是值得的。将一切都集中在一处真是太甜蜜了,让人无法放弃。
I'm late coming to this party, but I have a suggestion.
First, I agree with @Herbert - there's usually very little reason to ever run more than one Vim instance (console or otherwise). The advantages of keeping things in one instance is just too great. But, I see the need to mix in
-c
; although I can't see the need to do it myself :D.The best way I can see to get this functionality is to use the
--remote-send
feature of vim instead of--remote-silent
. This means a bit of shell scripting, however:I've only marginally tested that, but you should be able to do things like:
That should edit
file1
and move to the bottom of it. It should then also addfile2
,file3
andfile4
to the args list so that you can perform commands such as:bnext
. It should also revert to the same sort of functionality as--remote-silent
when you don't supply a-c
.I really think it's worth jumping through these hoops in order to properly integrate your command-line experience with a single Vim instance. Having everything in one place is just too sweet to give up.
我不认为运行多个 gvim 实例是一个不错的解决方案。为什么不只为
gvim --remote-silent
提供一个别名,当您不需要额外的开关(大概是大多数时间)时使用它,并为gvim< 提供另一个别名/code> 当你想添加命令行开关时?对我来说似乎很好,没有太多需要记住的。
运行多个 gvim 实例的主要缺点是,除了获得许多难以跟踪的窗口之外,每个 gvim 都有自己的运行时环境,更难在不同 gvim 实例的缓冲区之间共享和复制数据。
Derek Wyatt 在 --remote-silent 上有有趣的视频;我认为它不能解决您的问题,但您可能有兴趣观看:
OneVimToRuleThemAll
另外,如果问题是gvim 中的窗口分割会占用屏幕空间,更好地利用选项卡功能(您甚至可以禁用实际的选项卡标签,但保留打开的选项卡页的隐喻)和/或只是在缓冲区之间导航,同时只有一个缓冲区可见一次。
I don't think having multiple gvim instances running is a decent solution. Why not just have one alias to
gvim --remote-silent
that you use when you you don't need extra switches (presumably most of the time), and another alias to justgvim
for when you want to add command-line switches? Seems fine to me, not much extra to remember.The main unpleasantness from having multiple gvim instances running, aside from getting many windows that are hard to keep track of, is that each gvim has its own runtime envioronment, harder to share and copy data between buffers in different gvim instances.
Derek Wyatt has interesting video on --remote-silent; I don't think it addresses your issue but you may be interested in watching it:
OneVimToRuleThemAll
Also, if problem is that window splits within gvim are taking screen estate away, make better use of the tab functionality (you can even disable the actual tab labels but keep metaphor of open tab pages) and/or alternatively just navigate between buffers while having only one buffer visible at a time.
Derek Wyatt 的脚本很棒,在 MacOS 上做了一些修改:
brew install gnu-getopt
getopt
替换为/usr/local/opt/gnu-getopt/ bin/getopt
现在您可以将其放入 /usr/ local/bin 并在任何地方使用它
Derek Wyatt's script is awesome, made a couple of modifications on MacOS:
brew install gnu-getopt
getopt
with/usr/local/opt/gnu-getopt/bin/getopt
Now you can put this in /usr/local/bin and use it anywhere