[英]Open files with VIM in tabs instead of windows
I have searched and found threads related to this, but not exactly the same case. 我已经搜索并发现了与此相关的线程,但不完全相同的情况。
I use VIM in Windows7. 我在Windows7中使用VIM。 It's set as the default editor for text files. 它设置为文本文件的默认编辑器。 The problem is when I click in some text file in order to open it, it is opened in a new VIM window no matter if I already have one or more VIM windows opened. 问题是,当我点击一些文本文件,以打开它,它在一个新的VIM窗口打开不管,如果我已经有一个或多个VIM窗口打开。
How to change this behavior? 如何改变这种行为? Thanks! 谢谢!
UPDATE: This program solved my problem: http://defaultprogramseditor.com/ UPDATE:此程序解决我的问题: http://defaultprogramseditor.com/
vim has a "remote-server" concept, which allows you to open files in single/certain vim instance. vim具有“远程服务器”概念,该概念使您可以在单个/特定vim实例中打开文件。
vim's man page (help doc too: :h remote
) has the explanation. vim的手册页(也有帮助文档:h remote
)进行了说明。 in short: 简而言之:
vim --serverlist #list names of all found vim servers
vim --servername {name} #current instance becomes as server named {name}
vim --servername {name} --remote file #open file in {name} vim-server
You can still send keys to the remote vim, when the buffer load by --remote-send
or with command ... --remote +{cmd} file
当缓冲区通过--remote-send
或命令... --remote +{cmd} file
加载时,您仍然可以将密钥发送到远程vim。
For your requirement, you want to open files in a vim server's tab page, you could: 根据您的要求,您想在vim服务器的标签页中打开文件,您可以:
vim --servername FOO --remote-tab yourfile
You should manually set up your file associations in Windows to launch Vim with a custom command. 您应该在Windows中手动设置文件关联以使用自定义命令启动Vim。 If you're an administrator and don't mind messing with EVERYBODY's config, you can use the ftype
and assoc
commands in the cmd.exe shell. 如果您是管理员,并且不介意使用EVERYBODY的配置,则可以在cmd.exe Shell中使用ftype
和assoc
命令。 Otherwise, you can manually create registry entries in HKEY_CURRENT_USER\\Software\\Classes
. 否则,您可以在HKEY_CURRENT_USER\\Software\\Classes
手动创建注册表项。
The registry method actually sets up the same structure that you would set up automatically with ftype
and assoc
. 注册表方法实际上设置的结构与您使用ftype
和assoc
自动设置的结构相同。 First you must create a file type like "sourcecode" under that Classes key, with shell\\open\\command
key having the exact command you want to open Vim with, using %1
in place of the file name to pass in. Then create a association key like .c
with a value of the filetype you created, in this case "sourcecode". 首先,您必须在该Classes键下创建一个类似于“ sourcecode”的文件类型,其中shell\\open\\command
键具有您要打开Vim的确切命令,使用%1
代替要传递的文件名。然后创建一个关联密钥(如.c
,其值为您创建的文件类型,在本例中为“源代码”。
Some details on file associations here: http://vim.wikia.com/wiki/Windows_file_associations 有关文件关联的一些详细信息,请参见: http : //vim.wikia.com/wiki/Windows_file_associations
Specifically for setting up "launch in tabs" behavior, you want --remote-tab-silent, as done here: http://vim.wikia.com/wiki/Launch_files_in_new_tabs_under_Windows 专门用于设置“启动选项卡”行为,您需要--remote-tab-silent,如此处所述: http ://vim.wikia.com/wiki/Launch_files_in_new_tabs_under_Windows
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.