mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-02-03 23:40:14 +08:00
translated
This commit is contained in:
parent
cfc3c37b97
commit
2e76a83fd6
@ -1,138 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (hello-wn)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Top 10 Vim plugins for programming in multiple languages)
|
||||
[#]: via: (https://opensource.com/article/19/11/vim-plugins)
|
||||
[#]: author: (Maxim Burgerhout https://opensource.com/users/wzzrd)
|
||||
|
||||
Top 10 Vim plugins for programming in multiple languages
|
||||
======
|
||||
Make your life as a programmer or sysadmin a little better with these 10
|
||||
plugins for Vim.
|
||||
![OpenStack source code \(Python\) in VIM][1]
|
||||
|
||||
I've been a user of the [Vim][2] text editor for about two decades. For a little while, I have been customizing my Vim configuration, only using plugins for the last couple of years.
|
||||
|
||||
Recently, when I was redoing my setup (as I do every so often), I decided it was a good opportunity to identify the best Vim plugins for programming in multiple languages and a way to combine those plugins for each language I program in.
|
||||
|
||||
I do use certain plugins for specific languages and profiles (e.g., I only install Rocannon in my Ansible profile), and I won't go into those here—that would be a _long_ list. But the 10 Vim plugins described below are my favorites, the ones I use in virtually every profile I have, no matter what programming language I'm using.
|
||||
|
||||
### 1\. Volt
|
||||
|
||||
My number one pick isn't even a plugin; rather, it replaces plugins like [Vundle][3], so I'm listing it here.
|
||||
|
||||
[Volt][4] is a Vim plugin manager that lives outside Vim. You can use it to install plugins and create combinations of plugins called "profiles." You can enable a new profile with a single command: **volt profile set myprofile**. That way, I can do things like enable the [indentpython][5] plugin for just my Python profile. Volt also offers a simple way to do per-plugin configurations. The configuration is shared between profiles, so you can install plugins once and use them in multiple profiles.
|
||||
|
||||
Volt is still relatively new and not perfect (e.g., you can have just one configuration file per plugin, no matter how many profiles you are using), but apart from that, I find it extremely handy, extremely fast, and extremely simple.
|
||||
|
||||
![Volt plugin][6]
|
||||
|
||||
### 2\. Vim-Rainbow
|
||||
|
||||
Except for Python, virtually all major programming languages use brackets. Round ones, square ones, and curly ones. Often, they use multiple pairs of brackets, with one pair embedded in another. Figuring out which closing bracket belongs to what opening bracket can become difficult and annoying. I often find myself counting round brackets—especially in complicated Bash scripts—to make sure I got everything right.
|
||||
|
||||
Here's the [vim-rainbow][7] plugin to the rescue! It gives every pair of brackets a unique color, so it's easy to identify which brackets belong to each other. It's very useful and very colorful, too.
|
||||
|
||||
![vim-rainbow plugin][8]
|
||||
|
||||
### 3\. lightline
|
||||
|
||||
There are a lot of plugins for Vim, such as [Powerline][9], that put a bar at the bottom of the screen to show you what file you are working on, where you are in the file, what type of file it is, etc. Each of these plugins has advantages and disadvantages, and after briefly weighing them, I chose [lightline][10]. It's relatively small, easy to set up, quite extensible if you are into that kind of thing, and doesn't require any other tooling or plugins.
|
||||
|
||||
![Lightline plugin][11]
|
||||
|
||||
### 4\. NERDTree
|
||||
|
||||
[NERDTree][12] is a classic. In large projects, it can be hard to find the exact name and location of the one file that includes the one line you need to edit. With a quick keystroke (**F7**, in my case, as I bound NERDTree to F7 in my .vimrc configuration file), an explorer window opens in a vertical split, and I can easily browse to the file I want and open it. It's a must for large bodies of code. Or for people that tend to forget filenames, like me.
|
||||
|
||||
![NERDTree vim plugin][13]
|
||||
|
||||
### 5\. NERD Commenter
|
||||
|
||||
All programmers, at some time, write code that introduces a hard-to-debug problem that leads them to decide to comment out or undo the code. This is where [NERD Commenter][14] comes in. Select the code, hit **Leader+cc**, and your code is commented. (The standard Vim Leader key is the **/** character.) Hit **Leader+cn,** and your code is uncommented. NERD Commenter should automatically use the right commenting character for most file types. For example, if you are editing a [BIND zone file][15] and set the file type to bind zone, Vim will correctly use the **;** (semicolon) character to comment lines out.
|
||||
|
||||
![NERD Commenter][16]
|
||||
|
||||
### 6\. Solarized
|
||||
|
||||
I love my Vim colors. Really, I love terminal colors in general. I've been using the [Solarized][17] color scheme for Vim for a long time, and I set up my terminal, dir_colors, and Vim to be consistent.
|
||||
|
||||
Every now and then, though, I toggle between light and dark modes, depending on what kind of environment I'm in, the amount of light falling on my screen, and whether I need to put something on a big screen for others to read.
|
||||
|
||||
Obviously, you can grab any ol' color scheme you like, but I like the fact that Solarized has light and dark modes, an easy way to switch between the two, and it's not too intrusive. My second choice is [Monokai][18]. The Volt plugin manager makes it easy for me to switch between the two, so I can use Monokai for Python programming and Solarized for Bash.
|
||||
|
||||
I'm not including an image for Solarized, because all the other images in this article use Solarized light or dark, so check them out.
|
||||
|
||||
### 7\. fzf
|
||||
|
||||
When you're looking for a file, sometimes you want a file explorer, and sometimes you just want to ram something on your keyboard that vaguely resembles the filename you are looking for, amirite?
|
||||
|
||||
The [fzf][19] (or "fuzzy finder") plugin gives you just that. Hit **:FZF** and start typing. An ever-shortening list will show you files that more or less match what you are looking for. I use this a lot, probably even more than NERDTree these days. A slight downside is that this plugin has an external dependency in the fzf binary, so you'll have to install that, too. It's available for Fedora, Debian and, Arch, but I don't think it exists for EPEL.
|
||||
|
||||
![fzf Vim plugin][20]
|
||||
|
||||
### 8\. ack
|
||||
|
||||
Every once in a while, you want to search for a file that contains a certain line or a certain word. I really like the [ack][21] plugin for this, preferably in combination with **ag**, a command known as "the [silver searcher][22]." This combination is phenomenally fast and covers the vast majority of things I would use **grep** or **vimgrep** for. The downside is you'll need to install either ack or ag for it to work. The good news is that both ag and ack are available for Fedora and EPEL7.
|
||||
|
||||
![ack vim plugin][23]
|
||||
|
||||
### 9\. gitgutter
|
||||
|
||||
The majority of IT folks have worked with [Git][24] and files in Git repositories. The [gitgutter][25] plugin adds a column near your line numbers that shows symbols for changed (**~**), added (**+**), and removed (**-**) lines. This is quite useful for keeping track of what you have changed, and it keeps you focused on the task at hand, like writing a patch to fix one key bug. This plugin has a slight performance gap, and it sometimes takes a quick second for the plugin to catch up with your changes, but it's still quite useful.
|
||||
|
||||
![gitgutter vim plugin][26]
|
||||
|
||||
### 10\. Tag List
|
||||
|
||||
If you are programming in a file of any significant size, it's easy to lose track of where you are, and you might find yourself scrolling up and down looking for a certain function. With the [Tag List][27] plugin, you can just type **:Tlist** and get a vertical split with variables, types, classes, and functions that you can easily jump to. This works for a host of languages, like Java, Python, and any other file type the **ctags** utility works with … which is a lot.
|
||||
|
||||
![Tag List vim plugin][28]
|
||||
|
||||
So there you are: the 10 plugins for Vim that have made my life as a sysadmin and part-time programmer a little easier and a little better. What Vim plugins you are using? Please share your favorites in the comments.
|
||||
|
||||
Vim offers great benefits to writers, regardless of whether they are technically minded or not.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/11/vim-plugins
|
||||
|
||||
作者:[Maxim Burgerhout][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/wzzrd
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/openstack_python_vim_1.jpg?itok=lHQK5zpm (OpenStack source code (Python) in VIM)
|
||||
[2]: https://www.vim.org/
|
||||
[3]: https://github.com/VundleVim/Vundle.vim
|
||||
[4]: https://github.com/vim-volt/volt
|
||||
[5]: https://github.com/vim-scripts/indentpython.vim
|
||||
[6]: https://opensource.com/sites/default/files/uploads/vim-volt.gif (Volt plugin)
|
||||
[7]: http://github.com/frazrepo/vim-rainbow
|
||||
[8]: https://opensource.com/sites/default/files/uploads/vim-rainbox.png (vim-rainbow plugin)
|
||||
[9]: https://github.com/powerline/powerline
|
||||
[10]: http://github.com/itchyny/lightline.vim
|
||||
[11]: https://opensource.com/sites/default/files/uploads/lightline.png (Lightline plugin)
|
||||
[12]: http://github.com/scrooloose/nerdtree
|
||||
[13]: https://opensource.com/sites/default/files/uploads/nerdtree.gif (NERDTree vim plugin)
|
||||
[14]: http://github.com/scrooloose/nerdcommenter
|
||||
[15]: https://en.wikipedia.org/wiki/Zone_file#File_format
|
||||
[16]: https://opensource.com/sites/default/files/uploads/nerdcommenter.gif (NERD Commenter)
|
||||
[17]: https://github.com/altercation/vim-colors-solarized
|
||||
[18]: https://github.com/sickill/vim-monokai
|
||||
[19]: https://github.com/junegunn/fzf.vim
|
||||
[20]: https://opensource.com/sites/default/files/uploads/fzf.gif (fzf Vim plugin)
|
||||
[21]: https://github.com/mileszs/ack.vim
|
||||
[22]: https://github.com/ggreer/the_silver_searcher
|
||||
[23]: https://opensource.com/sites/default/files/uploads/ack.gif (ack vim plugin)
|
||||
[24]: https://opensource.com/resources/what-is-git
|
||||
[25]: https://github.com/airblade/vim-gitgutter
|
||||
[26]: https://opensource.com/sites/default/files/uploads/gitgutter.png (gitgutter vim plugin)
|
||||
[27]: https://github.com/vim-scripts/taglist.vim
|
||||
[28]: https://opensource.com/sites/default/files/uploads/taglist.gif (Tag List vim plugin)
|
@ -0,0 +1,139 @@
|
||||
[#]: collector: "lujun9972"
|
||||
[#]: translator: "hello-wn"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
[#]: subject: "Top 10 Vim plugins for programming in multiple languages"
|
||||
[#]: via: "https://opensource.com/article/19/11/vim-plugins"
|
||||
[#]: author: "Maxim Burgerhout https://opensource.com/users/wzzrd"
|
||||
|
||||
多语言编程必备的十大Vim插件
|
||||
======
|
||||
使用这 10 个 Vim 插件,可以让你在写代码或运维时,感觉更棒。
|
||||
|
||||
![OpenStack source code \(Python\) in VIM][1]
|
||||
|
||||
我使用 [Vim][2] 文本编辑器大约20年了。有一段时间,我一直在定制我的Vim配置,但在过去几年我会使用插件。
|
||||
|
||||
最近,当我重新安装 Vim 时(就像我经常做的那样),我决定把这次安装作为一次尝试,找到多种编程语言环境下的最佳 Vim 插件,以及如何将这些插件和每种语言结合起来。
|
||||
|
||||
有时,我会为特定的语言和配置使用特定的插件(例如,我只在 Ansible 配置中安装 Rocannon ),在此不细讲了。但是下面介绍的 10 个 Vim 插件是我的最爱,无论使用哪种编程语言,我几乎都会使用它们。
|
||||
|
||||
### 1\. Volt
|
||||
|
||||
我的首选并不是一个插件, 但是它可以替换类似于 [Vundle][3] 的插件,所以在此介绍。
|
||||
|
||||
[Volt][4] 是一个不依存于 Vim 的 Vim 插件管理器。 你可以用它安装插件,通过 `profiles` 组合使用不同的插件。你可以使用一个简单的命令 ```volt profile set myprofile``` 使得新 `profiles` 生效。 这样可以 因制宜地使用插件,比如,我在 Python 配置中单独使用 [indentpython][5] 插件。 Volt 还可以更方便地配置每个插件,这些配置会在 `profiles` 之间共享,因此只需要安装一次插件,就可以在多个 `profiles` 之间使用。
|
||||
|
||||
Volt 还是相对较新且不完美的(比如,无论使用多少 `profiles` ,每个插件只能有一个配置文件),但除此之外,我发现它非常方便、快速和简单。
|
||||
|
||||
![Volt plugin][6]
|
||||
|
||||
### 2\. Vim-Rainbow
|
||||
|
||||
除了 Python,几乎所有的主流编程语言都使用括号( 小括号,方括号和大括号)。 通常,它们会嵌套使用多对括号,因此很难搞清楚某个括号的开闭区间。我发现自己经常要数小括号,尤其是在复杂的 Bash 脚本中,以确保无误。
|
||||
|
||||
这时候就需要 [vim-rainbow][7] 插件! 它为每对括号设置不同的颜色,因此很容易识别出哪些括号是一对括号。 它非常有用而且五彩斑斓。
|
||||
|
||||
![vim-rainbow plugin][8]
|
||||
|
||||
### 3\. lightline
|
||||
|
||||
Vim 有很多插件,例如 [Powerline][9] ,它会在底部栏显示你正在处理的文件,光标所在的文件位置以及文件类型等信息。 这些插件各有利弊,在简单比较后,我选择了 [lightline][10]。 它相对较小,便于安装和扩展,并且不依赖于其他工具或插件。
|
||||
|
||||
![Lightline plugin][11]
|
||||
|
||||
### 4\. NERDTree
|
||||
|
||||
[NERDTree][12] 是一个很经典的插件。在大型项目中,你可能很难找到想要编辑的内容所在文件的确切名称和路径。使用快捷键(我使用的是 **F7** ,因为我在 `.vimrc` 中配置了这个快捷键),搜索窗会以垂直分屏的方式打开,就可以轻松找到所需文件并打开它。 对于大型项目,这是必备插件。 对于那些经常忘记文件名的人也很有用,比如我。
|
||||
|
||||
![NERDTree vim plugin][13]
|
||||
|
||||
### 5\. NERD Commenter
|
||||
|
||||
程序员们在写代码时,有时会遇到一些难以调试的问题,导致他们想要注释或不执行某段代码。 这时候就需要 [NERD Commenter][14] 出场了。选择代码段,按 **Leader键 + cc**,代码就会被注释掉。 (标准的 Vim Leader 键 是 **/** 字符。)按 **Leader键 + cn**,取消注释。 对于大多数文件类型,NERD Commenter 会自动使用正确的注释符。 例如,如果你正在编辑 [BIND区域文件][15],并将文件类型设置为绑定区域,Vim 会正确地使用 **;** (分号)字符进行注释。
|
||||
|
||||
![NERD Commenter][16]
|
||||
|
||||
### 6\. Solarized
|
||||
|
||||
我喜欢我的 Vim 主题配色。我也喜欢终端的主题色。我一直在 Vim 上使用 [Solarized][17] 配色,并且将我的终端、文件夹配色和 Vim 设为一致。
|
||||
|
||||
但是,有时我会根据周边环境,屏幕亮度以及是否需要分享投屏,切换明暗模式。
|
||||
|
||||
显然,你可以选择自己喜欢的任何配色方案,但我喜欢 `Solarized`,因为它有明暗模式功能,他可以简单快捷地切换两种模式。我的第二个选择是 [Monokai][18]。 Volt 插件管理器让我可以轻松地在两者之间切换,因此我在Python编程时,使用 Monokai ;Bash 编程时,使用 Solarized。
|
||||
|
||||
我没有给 Solarized 找相应的图片,因为本文中的所有其他图片都使用了 Solarized 中的浅色或深色效果,可以确认一下这些图片。
|
||||
|
||||
### 7\. fzf
|
||||
|
||||
当寻找一个文件时,有时你想要一个文件浏览器,有时你只想在键盘上敲打出与文件名类似的内容,对吗?
|
||||
|
||||
[fzf][19](全称 “模糊查找器”)插件提供了这一功能。打出 **:FZF** 并输入文件名内容。 不断缩短的列表将显示出与你输入的文件名内容相匹配的一些文件。我经常使用它,最近使用它的频率估计比使用 NERDTree 还多。缺点是这个插件依赖于 `fzf binary` ,因此也必须安装这个依赖包。它适用于 Fedora,Debian 和 Arch,据我所知并不适用于 EPEL。
|
||||
|
||||
![fzf Vim plugin][20]
|
||||
|
||||
### 8\. ack
|
||||
|
||||
有时,你需要搜索包含特定行或特定单词的文件。我真的很喜欢使用 [ack][21] 插件,最好与 **ag** 结合使用,他俩的组合又被称为 “[silver searcher][22]”。 这一组合的速度非常快,覆盖了 **grep** 或 **vimgrep** 的绝大多数使用场景。 缺点是您需要安装 ack 或 ag 才能正常运行。 好消息是 Fedora 和 EPEL7 都可以使用 ag 和 ack 。
|
||||
|
||||
![ack vim plugin][23]
|
||||
|
||||
### 9\. gitgutter
|
||||
大多数 IT 人员都使用 [Git][24] 和 Git 仓库中的文件进行工作。[gitgutter][25] 插件在行号附近添加了一列,通过符号显示该行的状态为,已更改(**~**),已添加(**+**)或者已删除(**-**)。这有利于跟踪你所做的更改,并且可以使你专注于手头的任务,例如编写补丁来修复一个关键 bug。
|
||||
|
||||
![gitgutter vim plugin][26]
|
||||
|
||||
### 10\. Tag List
|
||||
|
||||
如果你在一个很大的文件中编写代码,会很容易忘记当前所在的位置,你可能需要上下滚动来查找某个功能。使用 [Tag List][27] 插件,只需要输入 **:Tlist** ,就能垂直分屏显示出 包含变量、类型、类和函数的代码,你可以轻松跳转到这些变量、类型、类和函数。这个功能对于多语言同样适用,例如 Java 、Python 以及任何能够使用 **ctags** 功能的文件类型。
|
||||
|
||||
![Tag List vim插件] [28]
|
||||
|
||||
|
||||
以上介绍的 10 个 Vim 插件使我作为系统管理员和兼职程序员的生活变得更轻松。你正在使用哪些Vim插件?请在评论中分享你最爱的插件。
|
||||
|
||||
Vim 为写作者提供了很多便利,无论他们是否了解技术。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/11/vim-plugins
|
||||
|
||||
作者:[Maxim Burgerhout][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[hello-wn][c]
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/wzzrd
|
||||
[b]: https://github.com/lujun9972
|
||||
[c]: https://github.com/hello-wn
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/openstack_python_vim_1.jpg?itok=lHQK5zpm "OpenStack source code (Python) in VIM"
|
||||
[2]: https://www.vim.org/
|
||||
[3]: https://github.com/VundleVim/Vundle.vim
|
||||
[4]: https://github.com/vim-volt/volt
|
||||
[5]: https://github.com/vim-scripts/indentpython.vim
|
||||
[6]: https://opensource.com/sites/default/files/uploads/vim-volt.gif "Volt plugin"
|
||||
[7]: http://github.com/frazrepo/vim-rainbow
|
||||
[8]: https://opensource.com/sites/default/files/uploads/vim-rainbox.png "vim-rainbow plugin"
|
||||
[9]: https://github.com/powerline/powerline
|
||||
[10]: http://github.com/itchyny/lightline.vim
|
||||
[11]: https://opensource.com/sites/default/files/uploads/lightline.png "Lightline plugin"
|
||||
[12]: http://github.com/scrooloose/nerdtree
|
||||
[13]: https://opensource.com/sites/default/files/uploads/nerdtree.gif "NERDTree vim plugin"
|
||||
[14]: http://github.com/scrooloose/nerdcommenter
|
||||
[15]: https://en.wikipedia.org/wiki/Zone_file#File_format
|
||||
[16]: https://opensource.com/sites/default/files/uploads/nerdcommenter.gif "NERD Commenter"
|
||||
[17]: https://github.com/altercation/vim-colors-solarized
|
||||
[18]: https://github.com/sickill/vim-monokai
|
||||
[19]: https://github.com/junegunn/fzf.vim
|
||||
[20]: https://opensource.com/sites/default/files/uploads/fzf.gif "fzf Vim plugin"
|
||||
[21]: https://github.com/mileszs/ack.vim
|
||||
[22]: https://github.com/ggreer/the_silver_searcher
|
||||
[23]: https://opensource.com/sites/default/files/uploads/ack.gif "ack vim plugin"
|
||||
[24]: https://opensource.com/resources/what-is-git
|
||||
[25]: https://github.com/airblade/vim-gitgutter
|
||||
[26]: https://opensource.com/sites/default/files/uploads/gitgutter.png "gitgutter vim plugin"
|
||||
[27]: https://github.com/vim-scripts/taglist.vim
|
||||
[28]: https://opensource.com/sites/default/files/uploads/taglist.gif "Tag List vim plugin) ) ) "
|
Loading…
Reference in New Issue
Block a user