Common plugins
The reason that vim formed its own ecological environment, is because VIM has an open plug-in system, developers in order to improve development efficiency, for VIM to write tens of thousands of plug-ins, we can choose any choice, or based on the Vimscript language to develop their own proprietary plugins.
Each plugin is a vim-suffix script file, and the language used to write the plugin is generally vimscript. Vimscript is Vim's own programming language, and we'll introduce it in a follow-up. Although Vimscript can do almost anything for vim, there are still some scenes that are better and faster in other languages. With this in mind, Vim's developers have designed interfaces for other scripting languages to write Vim plugins, such as Perl,python and Ruby, and we'll show you how to use the Python language to write vim plugins for the go language and execute the GO program in vim.
Common plug-ins are divided into four types:
- Universal Plug-in: Applies to all types of files and can be paged out via plugin commands when using VIM. For example, to quickly locate a file plug-in Commandt, use to
:CommandT
start the function, for any type. This type of plug-in is typically placed under the. vim/plugin/directory.
- File type plug-ins: For specific types of files, such as C, Java, XML and other files. Plug-in functionality is enabled when editing a specific type of file, and the plug-in is typically placed under the. vim/ftplugin/directory. For example, we commonly used to edit xml/html/jsp files such as plug-in Xmledit, after installing the plugin, when editing the XML file, type
<modules>
, when finished >
, Xmledit will automatically add a closed tag for you, <modules></modules>
if you enter the last >
, the label expands automatically, allowing you to enter sub-labels or text content. If you open a TXT file with VIM, these functions will disappear. Of course, the Xmledit function is much more than that, and we'll cover it later.
- Syntax plug-in: As the name implies, syntax plug-ins mainly provide syntax highlighting for programming languages, usually placed under the. vim/syntax/. Vim already provides syntax highlighting for most languages by default, but for some newer languages, developers are required to write plugins that support syntax highlighting, such as the Go language.
- Compiler plug-ins: Compiler plugins written for different languages, primarily used to set compiler options for the relevant language. For example, for C, C + +, Java, Python can write their own compiler plug-ins, plug-in content is not complex, the main definition of "Errorformat" (Error format definition) and "MAKEPRG" (compiler and parameters) content can be.
:make
you can compile the file that you are editing by.
Understand the basic concept of VIM plug-ins, and then the following common plug-ins, it is more easily understood.
Pathogen
Let's start by introducing this plugin--pathogen for managing plugins.
1.
Https://github.com/tpope/vim-pathogen
2. Function description
A plug-in package often has a variety of functions, each file according to the path of the vim of the directory will be placed in different directories, the general plug-in into the plugin, the syntax highlighting plug-in syntax, the automatic loading plug-in autoload, file type plug-in placed under the Ftplugin, The encoded format plugin is placed under indent ... If you are a heavy plug-in user, you will find that there will be a lot of folders in the. Vim home directory, whether you want to install a new plugin, or want to delete the old plugin, is very troublesome, you have to find the relevant vim file under each folder.
Pathogen is a plug-in that manages plug-ins that are primarily used to address these issues. Pathogen uses the concept of bundles to manage plug-ins, and if you're familiar with OSGi or OS X, you're not unfamiliar with bundles. OSGi encapsulates Java programs and resource files in the form of bundles, and most of the applications in OS X are bundles, and it is the concept of bundles that allows OSGi to dynamically manage Java components, and most of the OS X installations are "green installations".
Pathogen the .vim
bundle file in the directory, all plugins will be managed under that directory. When Vim starts, the Vim script in the folder contained in the Runtimepath (RTP) list is automatically executed, and pathogen will ./vim/bundle
load the plug-ins in the folder below in a certain order recursively into RTP at startup, so that when Vim starts, Plug-ins that are managed through pathogen are in effect.
With pathogen, there are .vim
only three folders under the General folder: AutoLoad, Bundle, and Doc, and the other plugins will be installed under the bundle folder:
If no special instructions, the plug-ins mentioned later are installed in pathogen mode, I will use the Nerdtree plugin as an example of how to install.
3. Installation
.vim
Create AutoLoad and bundle directories under folders
- From getting the Pathogen.vim file, copy it to the AutoLoad directory
.vimrc
Add the following code to the file:
call pathogen#infect()
4. Instructions for use
No
5. Precautions
After installing the new plugin into the bundle directory, if the plugin contains doc, you will need to run it in vim :Helptags
to generate online help tags.
Nerdtree
When we introduced pathogen, we used a graph to show the directory structure of the plugin, which was implemented based on the Nerdtree plugin.
1.
Https://github.com/scrooloose/nerdtree
2. Function description
Nerdtree is one of the most commonly used plug-ins of vim, it can display the directory and file structure in vim runtime, similar to the file browser on the left side of TextMate, but it is more convenient to operate, you can quickly browse the files without leaving the keyboard, and switch between files and folders.
3. Installation
- Go to
.vim/bundle
Catalog
- Perform
git clone git://github.com/scrooloose/nerdtree.git
- After the download is complete, a Nerdtree folder is created under the bundle, and all related plugins are in the folder
- Run in vim
:Helptags
to generate Nerdtree online Help tags
4. Instructions for use
Turn on vim and enter :NERDTree
to exhale the file directory of the current directory where the VIM command is executed. For ease of use, I have defined shortcut keys in. VIMRC, you can use Ctrl+t to open nerdtree, you can define your own custom shortcuts.
Nerdtree provides a rich keyboard operation to browse and open files, I briefly introduce some common shortcut keys:
和编辑文件一样,通过h j k l移动光标定位o 打开关闭文件或者目录,如果是文件的话,光标出现在打开的文件中go 效果同上,不过光标保持在文件目录里,类似预览文件内容的功能i和s可以水平分割或纵向分割窗口打开文件,前面加g类似go的功能t 在标签页中打开T 在后台标签页中打开p 到上层目录P 到根目录K 到同目录第一个节点J 到同目录最后一个节点m 显示文件系统菜单(添加、删除、移动操作)? 帮助q 关闭
Want to know more ways to operate, can pass? See the detailed help information.
Command-t 1.
Https://wincent.com/products/command-t
2. Function description
COMMAND-T is a plug-in for fast file browsing based on Ruby and C extensions, similar to the textmate go to file (command+t out) feature, or the Open Resource (command+shift+r) feature of Eclipse , you can quickly locate and open a file with fuzzy matching.
3. Installation
- From downloading the latest version of the VBA file, the latest version is currently 1.4, so the installation file is Command-t-1.4.vba
~/.vim/bundle
Create a folder under the directory Command-t
- Open Command-t-1.4.vba with Vim
- Perform
:UseVimball ~/.vim/bundle/command-t
Go to the Ruby directory to compile the C extension
cd ~/.vim/bundle/command-t/ruby/command-t ruby extconf.rb make
4. Instructions for use
Input: Commandt can enter the file quick location function:
- ctrl+j/k Select File, select and enter to open file
- Ctrl+t opening a file in tab mode
- ctrl+s/v can open a file horizontally or vertically in a split window
- CTRL + C to exit the mode
The plugin also has a common command that :CommandTBuffer
can browse the buffer file and reopen it. Operation is the same as above.
5. Precautions
The VIM version needs to support Ruby extensions. We can enter the check in Vim :ruby 1
, if E319: Sorry, the command is not available in this version
it appears it is not supported.
If this is the case, we need to compile our own to support the vim of Ruby, it is troublesome to install Vim-nox directly, with Ruby support, the installation command in Ubuntu is as follows: sudo apt-get install vim-nox
.
ruby extconf.rb
If the MKMF package is not found when the command is executed, you will need to install the Ruby-dev package and install the command under Ubuntu as follows: sudo apt-get install ruby1.8-dev
.
Powerline 1.
Https://github.com/Lokaltog/vim-powerline
2. Function description
Powerline is the vim of a very beautiful status bar plug-in, after the installation of Powerline, VIM will appear on the bottom of a enhanced status bar, when vim in normal, INSERT, block, etc., the status bar will be rendered different colors, The status bar also displays the format of the currently edited file (uft-8, etc.), the file type (Java, XML, and so on), and the cursor location, as you like.
:
3. Installation
- Go to
.vim/bundle
Catalog
- Perform
git clone git://github.com/Lokaltog/vim-powerline.git
.vimrc
set the status bar theme in
"powerline{ set guifont=PowerlineSymbols\ for\ Powerline set nocompatible set t_Co=256 let g:Powerline_symbols = ‘fancy‘ "}
4. Instructions for use
Once installed, turn on Vim again and you'll see that there's already a colored status bar on the bottom.
To be continued, the fourth chapter intends to talk about Ctags, TagList, Foldmethod, Xmledit, Visualmark, Vim-markdown and so on, the fifth is about Python, go-related plug-ins, the sixth chapter on VIM programming skills, seventh chapter ...
"Turn" who says Vim is not an IDE? Three