VIM series: Preparations for project development using VIM

Source: Internet
Author: User


In Linux, the development time has been scattered for nearly a year and a half. At the beginning, VIM was used for simple code editing, during that time, I became familiar with VIM commands, edit mode switching, and Common commands in command mode. For the first time, I realized the power of VIM. In subsequent project development, although the Linux system is used, the main editing work of the application code is completed under Source Insight, and VIM is rarely used, so it is a little easy to use. However, we are still reluctant to find the concise, direct, and efficient way of VIM. We often learn VIM commands and skills and have been looking for opportunities to master the Project Development completed by VIM. In this project, the environment, opportunities (time, location, people, and so on) continue, and I am in the status ~~
Www.2cto.com 1. Familiar with basic shell commands and Common commands in Linux before using VIM for project development editing, familiar with the three modes and basic commands. Now the Linux release has installed VIM. If not, you need to install it yourself, preferably VIM7.0 or later, however, most distributions use the latest version by default. Unless you use the source code, pay attention to it. Ii. VIM configuration file and recommended VIM configuration file :. vimrc is generally located in the home directory of the user. This file determines the basic environment for starting VIM and the available commands and tools. It plays an important role in the use of VIM. There are many great powers on the network. the vimrc file provides reference and download, which are mostly complex and powerful, and highly associated with the system environment and the plug-ins used by the file. Therefore, it is best to ensure that the environment is consistent when downloading their files, otherwise, many functions will not be used, and sometimes some inexplicable problems may occur. In a later article, I will post a slightly rough. vimrc. The power of VIM lies in its highly customizable nature. You can create it as your own editor or IDE, which is achieved through collaboration between a large number of plug-ins and. vimrc configuration files. You can find various plug-ins on the VIM official website. If you do not find the plug-ins you need, you can also directly develop plug-ins and provide them to others. I have not reached this level. I recommend several commonly used plug-ins here:
Www.2cto.com buffexplorer plug-in: Used to browse and switch the buffer. The taglist plug-in is an indispensable tool for multi-file editing. It is used to view variables, macros, functions, and other units in the Code and locate and switch, development of the lookupfile plug-in is essential: Used to find files and buffers in the current directory environment, and switch between them. Five-star plug-in genutils plug-in: Use the general function plug-in NERD_Tree plug-in required by the lookupfile plug-in: displays and switches the directory tree of a specified directory in VIM, similar to the directory tree effect in windows Resource Manager, these plug-ins are useful for finding files in the entire file system on the VIM official website. You can download the latest version and install the plug-ins. VIM needs a runtime directory in the user's home directory :. vim/, if not, manually create the plug-in, and decompress all the downloaded plug-ins. install the plug-in the vim/directory. At this time, there are at least two directories under the. vim/directory: doc/and plugin/. The doc directory stores the help documents of each plug-in, and the plug-in directory stores the functions of each plug-in to implement the vim script. However, if the lookupfile plug-in is correctly installed. there should also be an autoload/directory under vim/, which contains the autoload vim script of the lookupfile and genutils plug-ins. They define some functions used by the lookupfile and genutils scripts in the plugin/directory. If there is no autoload directory, the lookupfile plug-in will not be available, and a similar error will be prompted: "E117: Unknown Function lookupfile # OpenWindow (...)". Therefore, if you find that there is no autoload directory after installation, You need to manually create the Directory and copy the vim script of the autoload version in the lookupfile plug-in and genutils plug-in packages. Plug-in help document generation: when using vim, one of the skills you must master is to be proficient in using vim's online help document, where you can find everything you need, but you need to know what you want to know. All the above plug-ins have complete help documents, but you need to add them to the vim online help system for ease of searching. This step is simple:
Switch www.2cto.com to the vim runtime directory and open vim: cd ~ /. Vim; vim in command mode, enter the following command: helptags doc, press enter to execute the command, and then OK. Now you can check the lookupfile help: help lookupfile. configure. after the vimrc file, VIM's own environment has been prepared so far, followed by an external auxiliary development environment. Iii. VIM external auxiliary Development Environment: VIM + Ctags + cs.pdf a single VIM tool is always insufficient. The philosophy in UNIX is that every tool is dedicated to accomplishing a small task, multiple tools are combined to accomplish a major event, so as to achieve unlimited possibilities with limited tools. VIM implements editing to the extreme. It provides some additional convenience for enhanced editing through plug-ins. However, the structured and data-based Management of code is obviously beyond the scope of VIM's functions, A more specific tool is required. This is the Ctags and cssag tools. The ctags tool extracts all the tags in the code file, including global variables, macros, functions, and data types, and records the positions and cross references of these tags in the file, in order to provide jump between these tags in the Code to facilitate tracing.
The www.2cto.com cs.tool also extracts all the tags in the code file, but it records more detailed data. By scanning the tag in the file, it creates a database, it provides more complex and powerful search functions such as search definition, function call, and called, text, and header files. During project development, these two tools are almost indispensable. VIM + Ctags + csags are generally the overall environment for project development (my current development environment ), this environment is ready for IDE development. The download and installation of the ctags and cssag tools are not described here. After installation, you can view the corresponding help manual using the following commands:

In subsequent articles, I will write a shell script using the two tools to manage and update the project development process.

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.