将 vimdiff 与不同的 .vimrc 一起使用?

发布于 2024-08-15 11:01:32 字数 369 浏览 1 评论 0原文

过去一周左右,我一直在使用 Vim 进行大部分编辑工作,我很喜欢这种体验。不过我有一个问题。

我已经使用 NERD_tree 和其他一些好东西设置了我的 .vimrc 文件。这对于我编码时非常有效。然而,有时我通过 Git 使用 vimdiff ,这会导致一些问题。当我执行此操作或在 .vimrc 文件中设置的许多其他操作时,我不需要打开 NERD_Tree

这是我的问题。有没有办法检查什么正在调用我的 .vimrc 文件并让它根据调用者执行不同的代码?具体来说,如何测试 vimdiff 是否是调用者?还是我的处理方式完全错误?

I've been using Vim now for most of my editing for the last week or so and I'm loving the experience. However I have an issue.

I've setup my .vimrcfile with NERD_tree and a few other goodies. This works well for when I'm coding. However on occasion I use vimdiff via Git and this causes some problems. I don't need NERD_Tree open when I do this or many of the other things I've setup in my .vimrc file.

Here's my question. Is there a way to check what is calling my .vimrc file and have it execute different code depending on the caller? Specifically how do I test to see if vimdiff is the caller? Or am I going about this entirely the wrong way?

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

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

发布评论

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

评论(2

潇烟暮雨 2024-08-22 11:01:32

摘自通过输入 :h diff 调用的 VIM 手册

if &diff
   setup for diff mode
else
   setup for non-diff mode
endif

Excerpt from the VIM manual called up by typing in :h diff

if &diff
   setup for diff mode
else
   setup for non-diff mode
endif
两相知 2024-08-22 11:01:32

你肯定想使用 Daniel Bruce 的解决方案——我怀疑你总是想要一个与 vim 不同的 vimdiff 配置,无论 git 是否在图中。

但是,如果您希望 vimdiff 与 git 一起使用而不是独立使用时有特定的行为,您可以为 gitconfig [diff] external 使用包装脚本,并且该脚本可以完全选择不同的 rc 文件。

Definitely you want to use Daniel Bruce's solution -- I suspect you always want a different configuration for vimdiff than for vim, whether git is in the picture or not.

But if you want particular behaviour for vimdiff when used with git as opposed to standalone, you can instead use a wrapper script for your gitconfig [diff] external, and the script could select a different rc file altogether.

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