在多个(新)选项卡中打开现有 Gvim 中的文件 [英] Open files in existing Gvim in multiple (new) tabs

查看:17
本文介绍了在多个(新)选项卡中打开现有 Gvim 中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 .bashrc 中放置了一些别名,以便在 gvim 中打开一组项目文件,每个文件都在它们自己的选项卡中:

I have put some aliases in my .bashrc to open a group of project files in gvim, each in their own tab:

gvim -p <list of file names using absolute paths>

这一切都很好,除了在任何给定时间我可能想要在几组文件之间移动(我当前的项目使用 Ruby on Rails,因此可以解释这一点).如果我可以将新选项卡附加到 gvim 的现有实例,那将是非常棒的.在我的最后一个职位上,我在 Vista 上工作;我通过在 gvim 中打开一堆空标签来解决这个问题,这使我可以右键单击文件名并选择在现有的无名 gvim 中打开".现在我使用 Ubuntu,上下文菜单上没有这样的东西.有没有办法从命令行执行此操作?

This is all well and good, except there are several groups of files I might want to move between at any given time (my current project uses Ruby on Rails, so that explains that). What would be really awesome is if I could append the new tabs to an existing instance of gvim. In my last position I worked on Vista; I got around this by opening a bunch of empty tabs in gvim, which allowed me to right-click on a filename and choose "Open in existing No-Name gvim." Now I use Ubuntu and there's no such thing on the context menu. Is there any way to do this from the command line?

推荐答案

如果 vim 是用 编译的clientserver 选项,你可以做到.使用以下标志启动您的 vim 实例:

If vim is compiled with the clientserver option, you can do it. Start your vim instance with the following flag:

$ gvim --servername GVIM  # GVIM is the server name. It can be anything.

要在此实例中打开更多选项卡,您可以运行以下命令:

To open more tabs in this instance, you can run the command:

$ gvim --servername GVIM --remote-tab file1 file2 file3 ...

vim 中的客户端服务器功能非常方便.它不仅限于打开文件;它可用于使用命令行向 vim 发送任何命令.比如远程关闭一个vim实例,可以使用:

The clientserver feature in vim is very handy. It's not limited to opening files; it can be used to send any command to vim using the command-line. For example, to close a vim instance remotely, you can use:

$ gvim --servername GVIM --remote-send '<Esc>:wqa<CR>'

这篇关于在多个(新)选项卡中打开现有 Gvim 中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆