在多个显示器上使用 vim

发布于 2024-09-28 11:00:12 字数 315 浏览 1 评论 0原文

我有三台显示器。

我通常在每台显示器上运行一个最大化的 xterm,连接到同一个 GNU screen 会话。

vim 可以使用类似的模型吗?是否可以运行三个 vim,全部共享相同的“vim 会话”:

  • 每个 vim 窗口显示不同的 vim 选项卡
  • 在所有窗口之间共享 vim 设置
  • 没有得到“交换文件...已经存在!”如果我在两个选项卡上打开同一文件,则会出现错误消息。

I have three monitors.

I normally run one maximized xterm on each monitor, attached to the same GNU screen session.

Can a similar model be used for vim? Is it possible to have three vims running, all sharing the same "vim session":

  • Each vim window showing a different vim tab
  • vim settings shared between all windows
  • Not getting the "Swap file ... already exists!" error message if I open the same file on two tabs.

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

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

发布评论

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

评论(5

倥絔 2024-10-05 11:00:12

我有一个工作解决方案,两个 vim 实例进行通信。

http://github.com/codeape2/vim-multiple-monitors

它使用 SwapExists如果检测到现有交换文件,则 autocmd 指示另一个实例打开文件。

I have a working solution where two vim instances communicate.

http://github.com/codeape2/vim-multiple-monitors

It uses the SwapExists autocmd to instruct the other instance to open a file if an existing swap file is detected.

萌辣 2024-10-05 11:00:12

您可以在 screen 下使用 vim

$ screen
$ vim

# on another terminal 
$ screen -x
# the same vim screen

如果您的终端模拟器支持选项卡(例如 gnome-terminal),您可以将其用作选项卡(恕我直言,gnome-terminals 的选项卡支持比 vim 自己的更好,除非您无法在不同的 vim 会话之间复制和粘贴,但是您可以改为使用系统复制粘贴缓冲区:“+y 和”+p)。

如果你使用 gvim,这不起作用。

You can use vim under screen.

$ screen
$ vim

# on another terminal 
$ screen -x
# the same vim screen

If your terminal emulator supports tabbing (e.g. gnome-terminal), you can use it as a tabbing (IMHO, gnome-terminals' tabbing support is better than vim's own, except perhaps you can't copy and paste among different vim sessions, however you can instead use the system copy-paste buffer: "+y and "+p).

This does not work if you're using gvim though.

忆梦 2024-10-05 11:00:12

不可以,Vim 实例仅限于桌面上的单个应用程序窗口。不同的 Vim 实例具有独立的会话。

此外,请注意,如果您在两个不同的 Vim 实例中打开同一个文件,您不仅会收到“交换文件存在”消息,而且这两个实例不共享缓冲区,因此在一个实例中所做的更改与其他实例无关。其他。

如果在一个实例中保存了更改的文件,当您返回到另一个 Vim 实例中的文件时,您将收到一条消息,提示“该文件自编辑开始以来已更改”,并询问您是否要重新加载该文件(这会将更改加载为由另一个实例保存,忽略您在当前实例中所做的任何更改)。

No, a Vim instance is limited to a single application window on your desktop. The different Vim instances have independent sessions.

In addition, be aware that if you open the same file in two different Vim instances, not only do you get the 'Swap file exists' message, but the two instances do not share a buffer, so changes made in one are independent of the other.

If a changed file is saved in one instance you will get a message when you return to the file in another Vim instance that 'the file has changed since editing started' and asking you if you want to reload the file (which would load changes as saved by the other instance, disregarding any changes you had made in the current instance).

污味仙女 2024-10-05 11:00:12

Neovim 是一个旨在为 vim 提供像 tmux 这样的附加/分离功能的项目。
此功能尚未实现(2015 年 6 月 19 日),但可能很快就会实现。

您可以在 neovim.io 上看到该项目的许多其他核心功能。

Neovim is a project that aim to give vim attach/detach feature like tmux.
This feature isn't yet implemented (june 19th 2015), but this may come soon.

There is many other core features for this project that you can see at neovim.io.

萌吟 2024-10-05 11:00:12

:设置无交换文件
:set autoread

缓冲区不会以这种方式共享,但如果保存文件,vim 会自动读取文件更改。并且您不会收到“交换文件存在”消息。

:set noswapfile
:set autoread

Buffers aren't shared this way but vim reads file changes automatically if you save it. And you don't get that 'Swap file exists' message.

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