vim中如何检测窗口的位置
我正在尝试自定义 vimdiff 的映射并使它们类似于 winmerge
在垂直 2 路分割中,我想映射 alt-left
将当前 diff 移动到左侧, alt-right
将当前差异移至右侧。
对于合并,我可以使用 :diffg
和 :diffp
。但我需要知道我所在的分区,以便我可以在其中使用 :diffg/:diffp
。
有什么方法可以检测我所处的分区。 具体来说,有什么方法可以让我知道光标是在左分割还是右分割
I am trying to customize the mappings for vimdiff and make them similar to winmerge
In a vertical 2 way split, I want to map alt-left <a-left>
to move current diff to left side and alt-right <a-right>
to move current diff to right side.
For merging i can use :diffg
and :diffp
. But I need to know which split i am in so that i can use :diffg/:diffp
in that.
Is there any way by which i can detect which split i am in.
Specifically is there is any way by which i can know whether the cursor is in left split or right split
Related Question
how-to-get-list-of-files-which-are-currently-being-diffed-in-vim
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设只有两个窗口,
winnr()
函数将为第一个窗口返回1
,为第二个窗口返回2
。您还可以使用winnr('$')
来了解有多少个窗口::echo winnr('$')
。您也可以只使用
dp
和do
,这样您就不需要在窗口之间跳转,而且比箭头键更容易到达。Assuming there are only two windows, the
winnr()
function will return1
for the first window and2
for the second window. You can also usewinnr('$')
to find out how many windows there are::echo winnr('$')
.You can also just use
dp
anddo
, then you don't need to jump betweem windows as much, and it's easier to reach than the arrow keys.不是您具体问题的答案,但这里有一些不错的差异调整可能会有所帮助。
我不喜欢 :diffon :diffoff 因为它们会扰乱自动换行(退出 diff 时将其打开)。所以我只设置 diff、scrollbind、foldmarker 和 Foldcolumn。
另外,如果您还没有的话,请检查 DirDiff 插件来比较目录树...
Not an answer to your specific question, but here are some nice diff tweaks that might help.
I don't like the :diffon :diffoff because they mess with word wrap (turns it on when exiting diff). So i only set diff, scrollbind, foldmarker and foldcolumn.
Also, check out the DirDiff plugin for diffing directory trees if you haven't already...