我可以将文件从一个 vifm 实例复制到另一个实例吗?

Can I copy a file from one instance of vifm to another?

我有多个 vifm 的已启动实例。是否可以将文件从一个实例复制到另一个实例(使用 yy)?

谢谢!

v0.10 之前

不,你不能轻易做到这一点。实例不共享它们的 运行-time 状态(在这种情况下是寄存器的内容),因此当您在其中一个中 yy 文件时,其他实例不知道它.

作为您真正需要的情况下的解决方法:

  1. (在 dst 实例中)运行 :write 将当前状态保存到 vifminfo 文件中。
  2. (在src实例中)做yy然后:write,这将合并两个实例的状态。
  3. (在 dst 实例中)运行 :restart 重新加载状态(这可以带来的不仅仅是寄存器)并执行 p.

这不是我真正推荐的东西,但它应该可以工作并且在某些情况下可能是可以接受的。

从 v0.10 开始

现在有 'syncregs' 选项,可以在实例之间共享寄存器。这是它的描述:

Specifies identifier of group of instances that share registers between each other. When several instances of vifm have this option set to identical value, they automatically synchronize contents of their registers on operations which use them.

因此,将此放入您的 vifmrc 应该就足够了:

set syncregs=general

或者需要分享的时候临时设置一下即可。

定义一个地图来保存当前文件:

nmap Wf :!ls -1 %f | while read f ; do printf ":!cp %%s/%%s %%s\n" %d $f '%%d' ; done > ~/.vifm_tmp <cr> 

第二个映射将作为临时文件的来源:

nmap Pf :source ~/.vifm_tmp<cr>

要复制文件:在第一个 vifm 实例中 Wf,然后在第二个实例中 Pf。这适用于多个选定(标记)文件,但不适用于可视模式。

也可以同步源码目录:

nmap Yd :!printf ":cd %%s\n" %d > ~/.vifm_tmp<cr> 
nmap Pd :source ~/.vifm_tmp <cr>                  

然后 copy/paste 在同一实例的面板之间。