[英]Switching quickly between versions
Let's say I have a file f.txt
under the git
repository. 假设我在git
存储库下有一个文件f.txt
。 The initial version of this file contains one line, version 2 contains 2 lines and every new version adds one line to the previous version, so the version 10 contains 10 lines. 该文件的初始版本包含一行,版本2包含两行,每个新版本在以前的版本中添加一行,因此版本10包含10行。
Now, I open the file f.txt
(in 5th version) in the vim editor. 现在,我在vim编辑器中打开文件f.txt
(第5版)。 I'd like to stay in the vim editor and have the possibility of commands like git_next
and git_previous
and quickly switch between versions, without having to know commit numbers and without leaving vim
. 我想留在vim编辑器中,并可以使用git_next
和git_previous
类的命令,并可以在版本之间快速切换,而不必知道提交号和不离开vim
。
Is there such a possibility of using git
and vim
? 有可能使用git
和vim
吗? It would be also useful if I could type command like git_versions
and I could choose from the list of versions of this file and switch to the desired version. 如果我可以键入git_versions
类的命令,并且可以从该文件的版本列表中进行选择,然后切换到所需的版本,这也将非常有用。
You are looking for Fugitive.vim plugin by Tim Pope. 您正在寻找Tim Pope的Fugitive.vim插件。 It can aid you with many git
commands. 它可以通过许多git
命令帮助您。
With fugitive.vim you can execute :Glog
and the revisions will be put into the quickfix
list. 随着fugitive.vim可以执行:Glog
和修改将投入quickfix
列表。 Just use :cnext
, :cprev
, and friends to move between the revisions. 只需使用:cnext
, :cprev
和朋友在修订版之间移动即可。 There is an excellent screencast, Fugitive.vim - exploring the history of a git repository , on this by Drew Neil. 有一个很好的截屏视频Fugitive.vim-在Drew Neil的基础上探索git存储库的历史 。 I would highly recommend watching all the Vimcasts on the subject. 我强烈建议您观看有关该主题的所有Vimcast 。
Drew in the screencast also shows off another Tim Pope plugin called Unimpaired.vim . 截屏视频中的Drew还展示了另一个名为Unimpaired.vim的 Tim Pope插件。 I highly recommend it. 我强烈推荐它。 It will provide some nice mappings ( [q
, ]q
, etc.) to move through the quickfix
list. 它将提供一些不错的映射( [q
, ]q
等),以在快速quickfix
列表中移动。
For more help see: 有关更多帮助请参阅:
:h quickfix
:h :cnext
If you have Fugitive.vim installed see: 如果您安装了Fugitive.vim,请参见:
:h fugitive
:h fugitive-:Glog
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.