Ubuntu install vim plugin steps

  
                

Source Insight is an editor with powerful features, but for Windows systems, which editor should Ubuntu use? Vim is a very good editor under Linux. The following small series will introduce you how to install the vim plugin on Ubuntu.

source insight is an excellent editor for windows, suitable for reading management code, mainly in the following functions:

Find function, variable, or macro definition.

Find the reference location of a function, variable, or macro.

Finding where the function is called

Finding all the matches of a symbol within a project

Since the unix philosophy advocates that a tool only does one thing, so under linux There is no such software that integrates multiple functions. Vim is a very good editor, this article describes how to install vim into the same or more powerful tools as source insight by installing plugins.

My environment is ubuntu12.04 LTS+vim version 7.3

1. ctags

The ctags plugin is used to find functions, variables or macro definitions, which can be very much under ubuntu. Easy installation,

sudo apt-get install exuberant-ctag

Execute the command in the source file directory

ctags -R

will generate a tag A file containing symbol information for all source files. In vim, the shortcut key ctrl+] will jump to the definition of the current function. In order to facilitate the production of tags, set the shortcut key F5 to generate the tag, add the following command to ~/.vimrc

nnoremap "F5" :! Ctags -R --c++-kinds=+p --fields=+iaS --extra=+q . CR

nnoremap represents the key mapping of vim normal mode,

--c++-kinds=+p : Add function prototype information to tags

-- Fields=+iaS : Add inheritance information, access control information, function signatures (such as parameter tables or prototypes) to tags.

--extra=+q : as class members Adding a class identifier to a tag

If the project has a multi-layered file structure, generally only a tag file is generated in the root directory, then the subdirectory cannot access the tag file, and opening the source file directly in the subdirectory will not find the function. A convenient way to add tags to the tags' search path in .vimrc is one for each item.

<;project1”

set tags+=/project1/tags

Shortcuts for ctags:

ctrl+] Switch to definitions

g+ctrl+] If there are multiple matches, list the matching tag list for selection

count+ctrl+t Back count tags

:count+tag advance count tags

:ts Lists matching tag lists. When there are multiple matches

:tn Skip to the next match tag

:tp Skip to the previous match tag

:tf jump to the ground a matching tag

:tl jump to the last matching tag

:set tags? View the tag file path

2.cscope

Ctags can only find the place where the symbol is defined. If you want to find similar function call lookup, symbol reference lookup and other advanced functions like sourceinsight, With the help of cscope. Cscope is a tool similar to ctags, but it's much more powerful than ctags.

Execute in the current source directory

cscope–Rbq

where

-R: recursively handle sub-layer directories

- b: automatically exit after generating the database

-q: generate cscope.in.out and cscope.po.out files, speed up the index of cscope

vim open cscope database after opening the source file To the current environment

:csadd cscope.out
Previous123Next page Total 3 pages

Copyright © Windows knowledge All Rights Reserved