Vim practical technology, Part 1: Common plug-ins

Source: Internet
Author: User
Tags doxygen ftp protocol

From: http://www.ibm.com/developerworks/cn/linux/l-tip-vim2/index.html

2.1. gzip (supported by compressed files)

Author:Bram moolenar

Website script No:None (included in the standard release of VIM)

Installation instructions:None

Function Description:

This script allows Vim to directly open files compressed using gzip [1], Bzip2 [2], and compress [3] (the corresponding command line tool is required ). Files suffixed with ".gz?".bz2" and ". Z" will be decompressed dynamically when they are opened and automatically recompressed during write operations.

When you open the compressed file, a (incorrect) "[noeol]" prompt appears on the screen.

2.2. netrw (Network File supported)

Author:Charles E. Campbell, Jr. (nicknamed dr. Chip)

Website script No:1075 (the standard release of VIM may include an older version)

Installation instructions:

The standard release of VIM 6.4 is 42, which is old and has incomplete functions, but does not require installation. Suggestion:

1. download version 62 on the vim website (the updated version can only be used for VIM 7 );
2. Use "Tar xvfj netr1_tar.bz2-C ~ /. Vim "unlock;
3. Run ": helptags ~" in vim ~ /. Vim/Doc "installation documentation.

Function Description:

Supports direct reading and writing of files on the network. The supported protocols include FTP, HTTP, rsync, and SCP. For example, you can use the FTP protocol to open the server with the user name Adah ~ The test. cpp file in the/TEMP directory can be directly used on the command line:

Vim ftp: // Adah @ server/temp/test. cpp

 

Vim will automatically prompt the user to enter the password and then open the file.

For more help information, see ": Help netrw ".

2.3. engspchk (English spelling check)

Author:Charles E. Campbell, Jr. (nicknamed dr. Chip)

Website script No:195

Installation instructions:
Download the latest version (engspchk.tar.gz) on the vim website );
Use "Tar xvfz engspchk.tar.gz-C ~ /. Vim "unlock;
Run ": helptags ~" in vim ~ /. Vim/Doc "installation documentation.
The system prompts that the spelling replacement function requires agrep [4] and may need to be downloaded and installed separately.

Function Description:
A spell checker dedicated to VIM. Its main features are:

    • The variables spchkdialect can be used to select English variants (UK, US, and Canada). Words that cannot be found, uncommon words, and words that are not in the current English variant are highlighted in different ways;
    • Supports user dictionaries (stored in the. Vim/cvimsyn directory) and project dictionaries (stored in the directory where the file to be checked is located );
    • ForSource codeFile. It only checks the spelling of comments, and does not protest against your variable name;
    • Dictionary files support languages other than English.

In the window shown in figure 5, engspchk is running. The red part is a word that cannot be recognized by the plug-in, and the yellow part is an incorrect spelling of the current English variant (default: American English, the cyan part is a rare word. The figure shows Vim that is supported by the graphic interface. Therefore, you can see a menu item named drchip (see figure 6). You can select the spelling check related functions through the menu; you can also see the shortcut key "\ EC" to start the spelling check, "\ ee" to end the spelling check, "\ ea" to replace the spelling, and so on. In text mode vim, we generally only use these shortcut keys.


Figure 5
 

Figure 6
 

For more help information, see ": Help engspchk ".

2.4. Calendar (calendar display)

Author:Yasuhiro Matsumoto

Website script No:52

Installation instructions:

Download the file calendar. Vim from the vim website and save it ~ /. Vim/plugin directory.

Function Description:

The lower part of Figure 6 is the running example of the calendar, which is displayed directly by typing "\ Cal" in normal mode. When the cursor is in this window, you can use the left arrow or up arrow to show the previous month, the right arrow or down arrow to show the next month, "T" back to "today ", Q closes the calendar window. You can double-click "Prev", "today", and "Next" with the help of a mouse.

In addition to "\ Cal", "\ Cal" can also open a calendar window, but the display position is on the left side of VIM rather than below. In addition, the ": Calendar" command has the same effect as "\ Cal", but it can be followed by parameters: one parameter represents the month, and the other two parameters represent the year and month respectively. ": Calendarh" is similar to ": Calendar", but the opening position of the calendar window is the same as "\ Cal" (rather than "\ Cal"), which is at the bottom, not on the left.

2.5. Project ("project" management of files)

Author:Aric blumer

Website script No:69

Installation instructions:

1. download the latest version (project-1.3.tar.gz) on the vim website );
2. Use the tar xvfz project-1.3.tar.gz-C ~ /. Vim "unlock;
3. Run ": helptags ~" in vim ~ /. Vim/Doc "installation documentation.

Function Description:

This plug-in can organize files into a tree for search and management. Run the ": Project" command to open a user's "project file "(~ /. Vimprojects ). Project files are in the form of common text files, which are very easy to browse and modify. Figure 7 is an example. The left-side window contains a project tree. The complete content is as follows:


Figure 7
 

Cvsmenu = "~ /. Vim "Cd =. {plugin/cvsmenu. Vim DOC/cvsmenu.txt} nvwa = "~ /Nvwa_local "Cd =. {Doc = Doc {changelog readme webupdate. sh} nvwa = nvwa {bool_array.cpp debug_new.cpp implements bool_array.h class_level_lock.h implements debug_new.h fast_mutex.h implements object_level_lock.h pctimer. h set_assign.h static_assert.h static_mem_pool.h }}

 

There are two projects in this project file: cvsmenu and nvwa. The content in the quotation marks indicates the path, and "Cd =." indicates that when the files in the project are opened, the current directory will be changed to the directory where the project is located. Under the project, you can add sub-projects. For example, there are two sub-projects named Doc and nvwa under the nvwa project. If there is no "Cd =.", the current directory is no longer changed when files in the sub-project are opened.

The complete content is not displayed in the figure, because the content can be folded (by default, the project file is fully collapsed when it is opened, that is, in the above example, only two projects named "cvsmenu" and "nvwa" can be seen "). You can double-click a non-filename line or press enter to expand or collapse it. You can use double-click or press enter to open the corresponding file on the filename line.

For more help information, see ": Help Project ".

2.6. taglist (SourceCodeStructure browsing)

Author:Yegappan Lakshmanan

Website script No:273

Installation instructions:

1. Make sure there is an available exuberant ctags version on the machine (you can run the "ctags" command ")

2. Download The taglist (assumed as taglist.zip) on the vim website );

3. Use "Unzip taglist.zip-D ~ /. Vim "unlock;

4. Run ": helptags ~" in vim ~ /. Vim/Doc "installation documentation.

Although the taglist uses ctags, the existence of the tags file is not required.

Function Description:

Use the ": tlist" command to enable/disable the taglist. For more information, see 1-8. Taglist has the following features:


Figure 8
 

    • Displays macro, function, variable, typedef, class, and struct information;
    • When opening multiple files, you can view the structure information of these files at the same time;
    • Double-click the name displayed in the taglist window on the left or press the Enter key. The corresponding defined position is displayed in the main window on the right;
    • The position of the cursor in the right window is changed, and the left window is highlighted in yellow within 4 seconds (default value, see ": Help 'updatetime;
    • When you enable/disable taglist, the plug-in can automatically change the size of the current Vim window (whether it is text mode vim or GUI Vim), unless you use ": let tlist_inc_winwidth = 0 "to disable this function (when using this function causes compatibility issues ).

For more help information, see ": Help taglist ".

2.7. cvsmenu (CVS integration)

Author:Thorsten maerz/Wu yongwei

Website script No:1245

Installation instructions:

1. Download The cvsmenu. Vim file from the vim website and save it ~ /. Vim/plugin directory;
2. start gvim and select "CVS-settings-install-Install Updates" from the menu (text mode Vim can use the shortcut key ", cgii"), from the Internet (SourceForge) (This step is optional ).

Function Description:

Integrate the version management function of CVS [24] In vim. This plug-in was originally written by Thorsten maerz and has not been maintained since 2002. After I started using this plug-in early 2005, I liked it very much. I fixed the errors and maintained the plug-in. If you find a bug, report it to me.

The main functions are shown in the menu shown in Figure 9:


Figure 9
 

    • understand basic information about the CVS environment and variable settings in cvsmenu (see figure 10).
      figure 10
    • adjust the settings and install the updated version.
    • Insert the Scalable Keywords of CVs, such as "$ date $" and "$ ID $".
    • perform basic operations on directories (such as CVS update).
    • basic operations for attaching parameters (file comparison, etc.);
    • management functions, such as logon.
    • delete a class operation.
    • tag
    • observation (Tracking) and editing functions
    • compare the local file with the files in CVS. (use the color highlighted in the left and right columns of VIM to display the comparison method of modifying, adding, and deleting parts. For the effect, see Figure 11 );
      figure 11
    • display the change and change time for each row of the file (CVS annotate, see Figure 12);
      Figure 12
    • displays the database access history (CVS history).
    • displays the file revision log (CVS log; see figure 13).
      Figure 13
    • displays the File status.
    • the status of a short file is displayed.
    • display the File status based on local information (the database is not accessed).
    • check out the module (CVS checkout);
    • query updates.
    • Update. CVs update is highlighted if any conflict exists.
    • cancel modification.
    • Add the current file to CVS (CVS add).
    • check in the current file (CVS commit);
    • CVS import
    • Add and check in the current file.

According to the actual needs, in addition to revision errors, I added some encoding-related support. Take the most practical case. If "set encoding = UTF-8" is used, but Chinese characters encoded by GBK are still used in the source code. in vimrc, add "Let G: cvscvsoutputencoding = 'gbk'" to ensure that the results of the "CVS annotate" operation are correct.

Thorsten designed the ease of use of the plug-in quite well. For exampleCompositionWhen comparing parts, you can press tab to jump to the next different place. Click "Q" in the comparison window on the left to close the window. For more help information, see ": Help cvsmenu ".

2.8. doxygen (the document comment syntax is highlighted)

Author:Michael Geddes

Website script No:5

Installation instructions:

1. download the latest cookbook (doxygen.zip) on the vim website );
2. Unzip doxygen.zip;
3. Run "CP-P doxygen. Vim ~ /. Vim/syntax and "CP-P doxygen.txt ~ /. Vim/Doc "copy the file to the vim directory;
4. Run ": helptags ~" in vim ~ /. Vim/Doc "installation documentation.
5. If ~ The/. Vim/after/syntax directory does not exist. Use "mkdir-P ~ /. Vim/after/syntax "to create the directory;
6. Enter ~ The/. Vim/after/syntax directory uses the following three lines to create associations between syntax files so that the comments can be recognized in C, C ++, And java files:

 

Ln-s http://www.cnblogs.com/syntax/doxygen.vim C. vimln-s http://www.cnblogs.com/syntax/doxygen.vim CPP. vimln-s http://www.cnblogs.com/syntax/doxygen.vim java. Vim"

 

6. (Optional) Check whether doxygen is correct on my personal programming page [6. vim updates (including the changes that the author has not incorporated into the standard release-Curious words, you can go to doxygen. in the vim file, take a look at how many times the name of Wu yongwei appears :-)).

Function Description:

If you have used document comments, I believe you don't need to talk about it. You will know the functions of this script after reading the 14-bit script. If you have not used document comments, we strongly recommend that you go to the doxygen [7] website to check out this useful tool. As an example, you can look at the code in the http://nvwa.sourceforge.net/doc/debug__new_8cpp.html#a17 using the HTML page automatically generated by doxygen.


Figure 14
 

2.9. Matrix (!)

Author:Don Yang

Website script No:1189

Installation instructions:

Download the file matrix. Vim from the vim website and save it ~ /. Vim/plugin directory.

Function Description:

Yes, it's about the movie Matrix! Not all Vim scripts are responsible for "proper work. Would you like to see the cool characters in the movie tumble in the vim window? Run the ": matrix" command (press any key to exit ). See Figure 15.


Figure 15

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.