Android extended series (8)-Vim plugin for convenient management (using git submodule and pathogen)

Source: Internet
Author: User
Tags how to use git using git

For a vimer, VIM plug-in management is actually a problem.
For a vimer who prefers to reinstall the system, VIM plug-in management is actually a very important issue.
For a vimer who likes and prefers the latest plug-ins and reinstalls the system, the management of VIM plug-ins is actually a more important issue.
So what I want to talk about is that the management of VIM plug-ins has different importance for different groups of people. I believe this is really an important issue that vimer wants to solve.

1. Several Problems about Vim plug-in management
What is the problem solved by the vim plug-in management?
(1). record archiving;
You can archive and view your personalized settings (. vimrc), plug-ins, operations, or documents you have prepared.
(2). cloud backup;
Cloud backup is safer than local storage, and we can get it anytime and anywhere through the network.
Reinstall the system and format it. You will not be afraid to forget to back up it later.
(3). can be updated;
In the simplest way, you can use the latest plug-ins and enjoy the latest improvements in the first time.
(4). Simple and Convenient;
With just a few simple operations, you can clone the same Vim running environment on your computer at any time.
It is absolutely simple and convenient. This is what we are pursuing.

2. Use git submodule and Pathogen
There is a solution that can solve the problems mentioned above.
Plug-in management, there is a famous Vim plug-in pathogen for convenient management.
You can use the GIT version control tool to implement backup records on GitHub.
Combined with the submodule feature in git, we can implement plug-ins to maintain their independence and update the plug-ins at any time.

3. Git and GitHub
This step is actually a basic condition of this article, and thanks to GitHub for providing such a good environment.
Git provides version management for later updates and modifications.
GitHub provides cloud-based backup that can be recovered anytime, anywhere. The most important thing is its perfect support for git.
Combined with GIT and GitHub, You can integrate local plug-ins and the entire environment into a good management system, which is simple, powerful, secure, and reliable.

4. Plug-in management pathogen plug-in
The benefit of this plug-in is that each plug-in can be independently put into the corresponding directory under the bundle, and all the plug-ins are very independent and clean.
Pathogen Source Code address: https://github.com/tpope/vim-pathogen
The usage of pathogen is described in detail above.
This plug-in type needs to be modified. vimrc, so we need to provide a. vimrc update method later. This problem will be discussed later.

5. Use git submodule
The GIT submodule implements the plug-in as a third-party version library embedded into our version library, and we only need to manage a version library.
Because the plug-ins are basically provided by others, and now Vim scripts is migrated to GitHub, we only need to clone them from GitHub.
However, each plug-in is an independent version library. If the plug-in is cloned separately, independent management may cause many local version libraries.
To use git submodule, you only need to create a version library, and use the version library of these plug-ins as a sub-module of the version library, which can simplify management, independent upgrades are available.
How to Use git submodule:

 
// Add a module git submodule add <URL> <local path> // update module git submodule initgit submodule update

6. Layout
Based on the above, we name this project openvims as an example. Its layout, that is, the directory structure, is as follows:

The previously mentioned. vimrc management problem is also solved through install. Sh here.

7. Verify
I have already set up this project on GitHub and named it openvims. Address:
Https://github.com/openproject/openvims
The verification procedure is as follows:

// First of all, what we need to do is clone the cost location. Vim directory git clone https://github.com/openproject/openvims.git ~ /. Vim // second, update the GIT submodule initgit submodule update of each Vim plug-in module. Finally, use. vimrccd ~ /. Vim./install. Sh

Now you can enjoy the convenience of openvims.
Open vim and try to see if it works.

8. Modify and upgrade
Modify the file, submit it using git, and upload it to the server.
To add a new Vim plug-in, run the following command:

 
// Take nerdtree as an example, execute git submodule add https://github.com/scrooloose/nerdcommenter.git bundle/nerdcommenter under the. Vim directory

If you update the plug-in, update it.

 
// Git submodule update under the. Vim directory

If you delete the directory, delete the plug-in folder under the bundle, and manually modify the. gitmodule. You can only do this, and finally submit it to the server.

9. Several plug-ins
(1). supertab
This plug-in is my favorite and easy to complete automatically.
Install the vim plug-in. I am the first to install this plug-in (not counting the vim plug-in management plug-in pathogen)
(2). File-line
A very convenient plug-in allows you to directly open the file and jump to a line. The only thing you need to do is to add ": Number" after the file parameter, which indicates your number of rows.
Application scenarios:


For example, if you use jgrep to search for the browser string in a project, the result is as follows:
There is a result in line 316. After installing this plug-in, we can directly use the following command to jump to line 316:

 
Vim./src/COM/Android/MMS/UI/messagelistitem. Java: 316

(3). nerdtree
Tree-type project view, which is easy to use. The effect is as follows: the official instructions of this plug-in are very detailed. I will not talk about it here.

I have a little experience talking about how to use nerdtree to open a project.
(3.1 ). you can use VIM + nerdtree to quickly open the current directory with nerdtree
(3.2 ). use an alias to quickly open a project anywhere. For example, in. in bashrc, alias openpro = 'CD/workspace/project; VIM + nerdtree' is defined. After openpro is executed in any directory, the project under the workspace directory can be opened.
(3.3). Configure shortcuts, such as F2.
(4 ). nerdcommenter
the plug-in for fast comment. After getting used to it, you can't leave this plug-in. "\" + "C" + "", now it's quite easy to use.
(5). Tabular
alignment plug-in is convenient.
select rows, and then: tabularize/=. All = of the selected rows are aligned. It is often used when writing Code to define variables.
not to mention, cut a picture to see the effect:


(6). Space
Use a space to repeat the plug-in. A clever plug-in is more powerful than. It just repeats the previous edit motion.
Small plug-ins. I believe you will like them after they are used.
I will add some useful plug-ins in the future. You are also welcome to reply and recommend some useful Vim plug-ins.

10. Summary
The Vim plug-in provides powerful extensions, but like the setting configuration file of the tool (but more complex), each type of person always has a custom solution, you also want to save the custom configuration scheme.
For the vim plug-in, it is recommended to upgrade the vim plug-in because of its complexity. This article provides a simple solution, hoping to help some vimer.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.