ArticleDirectory
- Pathogen
- Nerdtree
- Command-T
- Powerline
Common plug-ins
Vim has formed its own ecological environment because it has an open plug-in system. To improve development efficiency, developers have compiled tens of thousands of plug-ins for VIM. We can choose any one as needed, you can also develop your own plug-ins Based on the vimscript language.
Each plug-in is a script file suffixed with vim. The language for compiling the plug-in generally uses vimscript. Vimscript is owned by VIM.Programming LanguageWe will introduce it later. Although vimscript can do almost anything for VIM, there are still some scenarios where it is better and faster to use other languages. With this in mind, VIM developers have designed interfaces for other scripting languages to write Vim plug-ins, such as Perl, Python, and Ruby, we will demonstrate how to use python to compile the vim plug-in for the go language and execute goProgram.
There are four types of commonly used plug-ins:
- General Plug-In: applies to all types of files. When using vim, you can use the plug-in command to call out. For example, commandt, a plug-in used to quickly locate files, can be started using
: commandt
, and is applicable to any type. This type of plug-ins are generally stored in the. Vim/plugin/directory.
- file type plug-in: applies to files of specific types, such as C, Java, and XML. The plug-in function is enabled only when you edit a specific type of file. This type of plug-in is generally stored in the. Vim/ftplugin/directory. For example, we often use xmledit to edit XML, HTML, JSP, and other files. After this plug-in is installed, when editing the XML file, type
, after
is completed, xmledit automatically adds a closed tag for you.
, if you enter the last >
, the tag is automatically expanded to facilitate the input of sub-tags or text content. In this case, if you use Vim to open a TXT file, these functions will disappear. Of course, the xmledit function is far more simple than that. We will introduce it in detail later.
- syntax plug-in: as the name suggests, syntax plug-ins mainly provide syntax highlighting for programming languages, which are generally placed in. vim/syntax. Vim already provides syntax highlighting for most languages by default. For some newer languages, developers need to write plug-ins that support syntax highlighting, such as go language.
- compiler plug-in: Compiler plug-ins written in different languages are mainly used to set compiler options for relevant languages. For example, you can write compiler plug-ins for C, C ++, Java, Python, etc. The plug-in content is not complex and the main definition is "errorformat" (incorrect format definition) and "makeprg" (compile programs and parameters. You can use
: Make
to compile the files being edited.
After learning about the basic concepts of VIM plug-ins, it is easier to understand these commonly used plug-ins.
Pathogen
We will first introduce the plug-in pathogen for managing the plug-in.
1,
Https://github.com/tpope/vim-pathogen
2. Function Description
A plug-in package usually has multiple functions. Each file is placed in a different directory according to the vim path Convention. The General Plug-in is placed under plugin, And the syntax highlighting plug-in is placed under syntax, automatically load the plug-in under autoload, put the file type plug-in under ftplugin, and put the encoding format plug-in under indent ...... if you are a heavy plug-in user, you will find in. there will be a bunch of folders in the vim main directory. Whether you want to install new plug-ins or delete old plug-ins, It is very troublesome. You have to find the relevant Vim files in each folder.
Pathogen is a plug-in for managing plug-ins. It is mainly used to solve the above problems. Pathogen uses the bundle concept to manage plug-ins. If you are familiar with osgi or OS X, you will not be unfamiliar with bundle. Osgi encapsulates Java programs and resource files in the form of bundle, while most applications in OS X are bundle. It is the concept of bundle that enables osgi to dynamically manage Java components, most of OS X installation programs are "Green installation ".
Pathogen. Vim
Create a bundle file in the directory. All plug-ins are managed in the directory. When Vim is started, it will automatically execute the vim script in the folder contained in the runtimepath (RTP) List. pathogen will./Vim/bundle
The plug-ins in the folder under are recursively loaded to RTP in a certain order, so that the plug-in managed by pathogen takes effect when Vim is started.
With pathogen. Vim
There are only three folders in the folder: autoload, bundle, and Doc. Other ins will be installed in the bundle Folder ,:
Unless otherwise stated, all the plug-ins mentioned later are installed using the pathogen method. I will use the nerdtree plug-in as an example to describe the installation method.
3. Installation
- In
. Vim
Create the autoload and bundle directories under the folder
- Obtain the pathogen. Vim file and copy it to the autoload directory.
In. Vimrc
Add the followingCode:
Call pathogen # infect ()
4. Instructions for use
None
5. Notes
After the new plug-in is installed in the bundle directory, if the plug-in contains doc, run: Helptags
To generate online help tags.
Nerdtree
When we introduced pathogen, we used a figure to show the directory structure of the plug-in, which was implemented based on the nerdtree plug-in.
1,
Https://github.com/scrooloose/nerdtree
2. Function Description
Nerdtree is one of the most common plug-ins in Vim. It can display directories and file structures when running vim, similar to the file browser on the left side of textmate, but it is more convenient to operate, you can quickly browse files without leaving the keyboard and switch between files and folders.
3. Installation
- Enter
. Vim/bundle
Directory
- Run
Git clone git: // github.com/scrooloose/nerdtree.git
- After the download is complete, a folder named nerdtree will be added under the bundle. All the related plug-ins are in this folder.
- Run in VIM
: Helptags
To generate online help tags for nerdtree
4. Instructions for use
Open vim and enter: Nerdtree
To call out the file directory in the current directory where the vim command is executed. For ease of use, I have defined the shortcut key in. vimrc. You can use Ctrl + T to open the nerdtree, And you can define the shortcut keys you are used.
Nerdtree provides a variety of keyboard operations to browse and open files. I will briefly introduce some common shortcut keys:
Like editing a file, move the cursor through h j k l to locate o to open or close the file or directory. If it is a file, the cursor appears in the open file and the go effect is the same as above, however, the cursor remains in the file directory. Similar to the preview function of the file content, I and s can be split horizontally or vertically to open the file, previously added G-like go function T Open t in the tab t open P to the upper directory P to the root directory K to the first node J in the same directory to the last node in the same directory M Displays the file system menu (add, delete, and move operations )? Help Q close
For more operation methods, can I use? View Detailed Help information.
Command-T 1,
Https://wincent.com/products/command-t
2. Function Description
Command-T is a plugin for Fast File Browsing Based on Ruby and C extensions. It is similar to textmate's go to file (command + T outbound) function, or eclipse's open Resource (command + Shift + r) function, you can quickly locate and open the file through fuzzy match.
3. Installation
- Download the VBA file from the latest version, the latest version is 1.4, so the installation file is a command-t-1.4.vba
- In
~ /. Vim/bundle
Command-T
- Open command-t-1.4.vba with vim
- Run
: Usevimball ~ /. Vim/bundle/command-T
Go to the ruby directory and compile the C extension.
Cd ~ /. Vim/bundle/command-T/Ruby/command-T Ruby extconf. RB make
4. Instructions for use
Input: commandt to go to the file quick locating function ,:
- CTRL + J/K select files up and down, select files, and press enter to open the file
- CTRL + t open the file as a tab
- CTRL + S/V can open files in a horizontal or vertical split window
- CTRL + C Exit this mode
This plug-in also has a common command,: Commandtbuffer
You can browse the buffer file and open it again. The operation method is the same as above.
5. Notes
The Vim version must support Ruby extensions. We can enter: Ruby 1
Check ifE319: Sorry, the command is not available in this version
Is not supported.
If the above problem occurs, we need to compile Vim that supports Ruby by ourselves. If it is too troublesome, we can directly install vim-NOx with Ruby support. The installation command in Ubuntu is as follows:Sudo apt-Get install vim-NOx
.
RunRuby extconf. Rb
If the mkmf package cannot be found during the command, you need to install the ruby-dev package. The installation command in Ubuntu is as follows:Sudo apt-Get install ruby1.8-Dev
.
Powerline 1,
Https://github.com/Lokaltog/vim-powerline
2. Function Description
Powerline is a very beautiful status bar plug-in of VIM. After Powerline is installed, an enhanced status bar will appear at the bottom of VIM. When Vim is in normal, insert, block, and other States, the status bar shows different colors, and the status bar also displays the current editing file format (uft-8, etc.), file type (Java, XML, etc.) and the cursor position, like to install.
:
3. Installation
- Enter
. Vim/bundle
Directory
- Run
Git clone git: // github.com/lokaltog/vim-powerline.git
In. Vimrc
Set the status bar topic
"Powerline {set guifont = powerlinesymbols \ for \ Powerline set nocompatible set t_co = 256 Let G: powerline_symbols = 'fancy '"}
4. Instructions for use
After the installation, open Vim again and you will find that there is a colored status bar at the bottom.
the fourth article is about ctags, taglist, foldmethod, xmledit, visualmark, and vim-markdown, the fifth part is about Python and go plug-ins, the sixth part is about Vim programming skills, and the seventh part is ......