Vim在从`git commit`调用时使用非标准配置? [英] Vim using non-standard configuration when called from `git commit`?

查看:73
本文介绍了Vim在从`git commit`调用时使用非标准配置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到,git似乎在我编写提交消息时使用了不同的vim设置。我有 git + svn install off Macports,并且检查了 $ MYVIMRC 变量:它被设置为正确的文件。尽管如此,每次我提交一条消息时,我都会限制每行80个字符,区分大小写的搜索,以及我没有安装的插件。



可能有些愚蠢。将欣赏一个指针是什么。



编辑:其实我只是检查:我的插件工作。当我输入提交消息时,只有80个字符的列宽奇迹般地活跃起来。

解决方案

这不是一个bug,它是一个功能!知道很多文件类型 - 包括git提交(和交互式rebase,以及配置...)。每种语法都有语法定义和ftplugins(文件类型激活的插件)。提交ftplugin中的一个设置是 textwidth = 72 。这样做是为了让git log的输出在标准宽度的终端中看起来不错。如果你真的想改变它,你可以编辑插件,但我真的建议保留它。



插件应该在 < VIM-目录> /vimXX/ftplugin/gitcommit.vim XX 是版本号,例如, 72版本7.2,而主要组件通常类似于 / usr / share / vim 。该插件还定义了一个命令DiffGitCached,它将打开要在预览窗口中提交的差异。方便!

I've noticed that git seems to use different vim settings any time I'm writing a commit message. I have the git+svn install off Macports, and I've checked the $MYVIMRC variable: it's set to the correct file. Still, every time I go to commit a message I have a restriction on 80 characters per line, case sensitive search, and none of the plugins I've installed.

It's probably something silly. Would appreciate a pointer as to what it is.

EDIT: Actually I just checked: my plugins work. It's only the column width of 80 chars that miraculously comes alive when I type out commit messages.

解决方案

That's not a bug, it's a feature!

Vim knows about a lot of filetypes - including git commits (and interactive rebases, and config...). There are syntax definitions and ftplugins (filetype-activated plugins) for each of these. One of the settings in the commit ftplugin is textwidth=72. This is done so that the output of git log will look good in a standard-width terminal. If you really want to change it, you could go edit the plugin, but I'd really recommend keeping it.

The plugin should be in <vim-directory>/vimXX/ftplugin/gitcommit.vim. The XX is the version number, e.g. 72 for version 7.2, and the leading component is generally something like /usr/share/vim.

P.S. The plugin also defines a command DiffGitCached, which will open the diff to be committed in a preview window. Handy!

这篇关于Vim在从`git commit`调用时使用非标准配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆