我可以强制 gVim 在新选项卡中打开拖入的文件吗?

发布于 2024-08-14 05:41:13 字数 211 浏览 1 评论 0 原文

我希望 gVim 打开拖入其中的文件以在新选项卡中打开,而不是替换当前文件。 这个问题是正确的,但我想能够运行 gVim 的多个实例,只需将文件拖到我想要的窗口即可。

我在 Windows 7 上运行。

I'd like gVim to open files dragged into it to open in a new tab, instead of replacing the current file. This question is on the right track, but I'd like to be able to run multiple instances of gVim, just able to drag files to the window I want.

I'm running on Windows 7.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

深海少女心 2024-08-21 05:41:13

不,您不能,拖放的默认操作是在 Windows 应用程序的实现中指定的 (OLE DoDragDrop)。它尚未实现在新选项卡中打开删除的文件,因此不会。但 gVim 是开源的……所以如果你真的想要这个,你可以提交补丁:)

No you cannot, the default action on drag and drop is specified in the implementation of a windows application (OLE DoDragDrop). It has not been implemented to open dropped files in a new tab and thus won't. But gVim is open source... so you could submit a patch if you really want this :)

落叶缤纷 2024-08-21 05:41:13

您可以首先输入 :tabe,然后拖放文件。我无法完全确认这一点(我只有一台 Mac),但我认为这最终会显示 :tabe filename 。然后你可以按回车键然后就可以了......

You can start by typing :tabe and then drag and drop your file. I can't fully confirm this (I only have a mac) but I think this will end up with :tabe filename displayed. You can then hit enter and off you go...

末が日狂欢 2024-08-21 05:41:13

您可以在 .vimrc 中添加以下内容,

autocmd BufReadPost * tab ball

这将为所有缓冲区打开选项卡,包括新删除的文件。请注意,它对所有缓冲区执行此操作,对于已在gvim中打开的缓冲区也是如此。

You could add the following in your .vimrc

autocmd BufReadPost * tab ball

This will open tabs for all buffers, including the newly dropped file. Notice it does so for all buffers, so also the ones already opened in gvim.

夏末 2024-08-21 05:41:13
  1. 将文件拖到 Vim 时按住 CTRL 将在 Vim 中的新窗口中打开新文件。
  2. 然后只需使用 T 正如我在此处找到的那样,将该拆分转换为新选项卡。
  1. Holding CTRL while dragging the file to Vim will open the new file in a new window split in Vim.
  2. Then simply convert that split to a new tab with <C-W>T as I found here.
清晰传感 2024-08-21 05:41:13

在 gvim 中打开新文件不会替换当前打开的文件。新文件在新缓冲区中打开,并显示该缓冲区。您可以使用 :b 命令在缓冲区之间切换。在您的情况下,您只需删除文件,然后使用 :tabedit 创建一个新选项卡,并使用 :b 将该选项卡缓冲区切换到您想要的选项卡>。当然,这并不完全是您要寻找的,但对我来说已经足够了。

Opening a new file in gvim doesn't replace the one that's currently open. The new file is opened in a new buffer and that buffer is show. You can switch between buffers using the :b command. In your case, you can simply drop the file, then create a new tab with :tabedit, and switch that tabs buffer to the one you want with :b <filename>. Of course that's not exactly what you're searching for, but it's sufficient for me.

溺渁∝ 2024-08-21 05:41:13

您可以将以下选项添加到 vimrc 中。 VIM 将使用新选项卡打开文件。您还可以拖放到 gVim,它将在新选项卡中打开。它对我有用,我也在 Windows 7 上使用。

:au BufAdd,BufNewFile * 嵌套制表符球

You can put the following option to vimrc. VIM will open the file with new tab. You can also drag and drop to gVim, it will open in new tab. It works for me, I'm also using on Windows 7.

:au BufAdd,BufNewFile * nested tab sball

吃颗糖壮壮胆 2024-08-21 05:41:13

这些 Windows 友好的映射可以使这个问题更容易忍受。不过,仍然必须记住在拖动文件之前按 Ctrl-T...

" CTRL-T opens a new tab, CTRL-W closes tab, CTRL-Left/Right switches tabs
noremap   <C-T> :tabnew<return>
noremap   <C-W> :tabclose<return>
noremap   <C-Left> :tabprevious<return>
noremap   <C-Right> :tabNext<return>

These Windows friendly mappings can make this problem more bearable. Still have to remember to press Ctrl-T before dragging the file though...

" CTRL-T opens a new tab, CTRL-W closes tab, CTRL-Left/Right switches tabs
noremap   <C-T> :tabnew<return>
noremap   <C-W> :tabclose<return>
noremap   <C-Left> :tabprevious<return>
noremap   <C-Right> :tabNext<return>
扭转时空 2024-08-21 05:41:13

由于文件无法正确拖放到 gvim,因此我使用批处理文件来完成此操作。拖动的文件可以拖放到批处理文件或其快捷方式中。它也可以用在 Windows 资源管理器的发送到菜单中。

这是批处理文件的内容(更改gvim服务器的路径和名称):

@ECHO OFF
:TOP
IF (%1) == () GOTO END
    I:\apps\vim\vim73\gvim.exe --servername GVIM --remote-tab "%1"
SHIFT
GOTO TOP

:END
ECHO End

Since files cannot be drag and dropped to gvim correctly, I use a batch file to accomplish this. The dragged files can be dropped to the batch file or a shortcut to it. It may also be used in the send to menu of windows explorer.

Here is the content of the batch file (change the path and the name of the gvim server):

@ECHO OFF
:TOP
IF (%1) == () GOTO END
    I:\apps\vim\vim73\gvim.exe --servername GVIM --remote-tab "%1"
SHIFT
GOTO TOP

:END
ECHO End
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文