How can we create vim as source insight in Linux? (Instance tutorial), viminsight

Source: Internet
Author: User
Tags define function switch case

How can we create vim as source insight in Linux? (Instance tutorial), viminsight

As we all know, the source insight in windows is an artifact for reading project code. Its magic is that it can be used to globally search for the definition of this function or variable based on the function name or variable referred to by the current mouse, it also displays

Shows which files also contain the function definition, and lists the variables and functions in the current file. Therefore, it is especially suitable for reading and managing large project code with source insight in windows. But not in Linux.

Install source insight, while vim and Emacs are the artifacts for editing code in linux. Their vim functions can be expanded through a series of plug-ins, which is convenient and open-source, after one afternoon of hard work, I finally achieved a simple and strong performance.

Building a big vim environment, of course, I did not install the code complementing function plug-in order to cultivate the code farming capability. The following is a result of the tossing:

I used ubuntu 14.10 because many software sources in China do not support the upgrade of this version. After you have installed ubuntu, vi is installed by default. At this time, you must install

Vim:

sudo apt-get install vim

In this case, you can use the following command to check whether the installation is successful:

vim --version

Then install the plug-in.

Before installing the plug-in, you must first install ctags. Because the plug-in Taglist is based on the tags file, ctags are required to generate the tags file. To install ctags in ubuntu, enter the following command on the terminal:

sudo apt-get install ctags

Then, install the vim plug-in the following order:

Taglist plugin

Directory, which has two directories: doc

And plugin respectively, copy the files under the two directories to the doc and plugin directories in vim. In this operation, you need to first find the decompressed file, and then enter:

cp doc/taglist.txt /usr/share/vim/vim74/doc/cp plugin/taglist.vim /usr/share/vim/vim74/plugin/

At the same time, you can set your own vim parameters and enter the following in the terminal:

vim ~/.vimrc

In this file, enter:

// Syntax highlight syntax on // display the row number set number // auto indent and C language style indent set autoindentset cindent // indent width set tabstop = 4 set softtabstop = 4 set shiftwidth = 4/ /We recommend that you enable the expandtab option, the tab will be automatically expanded with spaces, and the code indent will be more beautiful set expandtab // switch case alignment style set cino = g0 ,: 0 // set taglistlet Tlist_Show_One_File = 1 // only display the current file's tagslet Tlist_WinWidth = 30 // set the taglist width let Tlist_Exit_OnlyWindow = 1 // The tagList window is the last window, exit Vimlet Tlist_Use_Left_Window = 1 // display the taglist window on the left of the Vim window

2. SrcExpl plug-in

This plug-in is a search function. It is in the lower box and can be downloaded from an online address. The installation process is the same as that of the Taglist plug-in, copy the files under the two directories to the vim doc and plugin, and then

Modify the. vimrc file under vim. The open-source plug-in provides an example. For details, refer to its official open-source address.

3. Trinity plug-in

This plugin contains NERD_tree.vim and trinity. vim.

NERD_tree is the rightmost function box in the graph. This is to implement the file tree function, and the Trinity file has a trinity. vim, which is to implement the function of Quickly switching between the three function boxes. You can perform the following operations from an online address:

. Decompress the file and copy the NERD_tree.vim trinity. vim plug-ins to the plug-in folder under the vim installation directory, and then modify the/. vimrc file. For details about how to modify the modification, refer to the official github website.

After the modification, F8 is used to open and close all function boxes. F9 is used to open and close the SourceExplorer function box, and the rest are related key control function boxes. You can define function keys by yourself. Another function of F10 is

The content of the new ctags. If the code is changed, save and press F10 to update the ctags. Of course, if set mouse = a is added, you can use the mouse in vim.

In this case, run ctags-R in the project directory, use vim to open a file, press F8 (open all function boxes), and try again to see if it is the same as source insight.

Go to the file in the preview box and double-click the mouse in the preview box. To return, press the Space key.

So far, the effect can be achieved.

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.