加入收藏 | 设为首页 | 会员中心 | 我要投稿 核心网 (https://www.hxwgxz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 建站 > 正文

5个好用的开发者Vim插件

发布时间:2019-02-26 14:04:25 所属栏目:建站 来源:Ricardo Gerardi
导读:通过这 5 个插件扩展 Vim 功能来提升你的编码效率。 我用 Vim 已经超过 20 年了,两年前我决定把它作为我的首要文本编辑器。我用 Vim 来编写代码、配置文件、博客文章及其它任意可以用纯文本表达的东西。Vim 有很多超级棒的功能,一旦你适合了它,你的工作

Vim Fugitive 是另一个将 Git 工作流集成到 Vim 中的超棒插件。它对 Git 做了一些封装,可以让你在 Vim 里直接执行 Git 命令并将结果集成在 Vim 界面里。这个插件有超多的特性,更多信息请访问它的 GitHub 项目页面。

这里有一个使用 Vim Fugitive 的基础 Git 工作流示例。设想我们已经对下面的 Go 代码做出修改,你可以用 :Gblame 调用 git blame 来查看每行最后的提交信息:

  1. e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│    1 package main
  2. e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│    2
  3. e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│    3 import "fmt"
  4. e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│    4
  5. e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│_   5 func main() {
  6. e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│    6     items := []string{"tv", "pc", "tablet"}
  7. e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│    7
  8. 00000000 (Not Committed Yet 2018-12-05 18:55:00 -0500)│~   8     if len(items) > 0 {
  9. e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│    9         for _, i := range items {
  10. e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│   10             fmt.Println(i)
  11. 00000000 (Not Committed Yet 2018-12-05 18:55:00 -0500)│+  11             fmt.Println("------")
  12. e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│   12         }
  13. e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│   13     }
  14. e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│   14 }

可以看到第 8 行和第 11 行显示还未提交。用 :Gstatus 命令检查仓库当前的状态:

  1.   1 # On branch master
  2.   2 # Your branch is up to date with 'origin/master'.
  3.   3 #
  4.   4 # Changes not staged for commit:
  5.   5 #   (use "git add <file>..." to update what will be committed)
  6.   6 #   (use "git checkout -- <file>..." to discard changes in working directory)
  7.   7 #
  8.   8 #       modified:   vim-5plugins/examples/test1.go
  9.   9 #
  10.  10 no changes added to commit (use "git add" and/or "git commit -a")
  11. --------------------------------------------------------------------------------------------------------
  12.     1 package main
  13.     2
  14.     3 import "fmt"
  15.     4
  16. _   5 func main() {
  17.     6     items := []string{"tv", "pc", "tablet"}
  18.     7
  19. ~   8     if len(items) > 0 {
  20.     9         for _, i := range items {
  21.    10             fmt.Println(i)
  22. +  11             fmt.Println("------")
  23.    12         }
  24.    13     }
  25.    14 }

(编辑:核心网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读