如何使用vim作为"git log"编辑器?

问题描述:

运行git log时,git log使用的编辑器到底是什么?

When I run git log, what exactly is the editor git log is using?

也:

  1. 反正我可以使用vim作为git log的默认编辑器吗?
  2. 如果我要搜索git日志,最好的方法是什么?现在,我正在执行以下操作:git log | grep bla.
  1. Is there anyway I can use vim as my default editor for git log?
  2. If I want to search against the git log, what's the best way? Now I'm doing something like: git log | grep bla.

默认情况下,git log命令将其输出通过管道传递到 pager ,而不是编辑器.在大多数系统上,此寻呼机通常为lessmore.您可以使用以下命令将默认的寻呼机更改为vim:

The git log command pipes it's output by default into a pager, not an editor. This pager is usually less or more on most systems. You can change the default pager to vim with the command:

git config --global core.pager 'vim -'

现在,您可以像往常一样使用vim功能和/进行搜索了.

Now you can search using vim functionality with / as usual.