Vim

  • Vim is a text editor which based on Vi editor common to Unix-like systems.
  • Vim supports commands for tracing codes:
    • /word : Search word from top to bottom
    • ?word : Search word from bottom to top
    • /jo[ha]n : Search john or joan
    • /fred\|joe : Search fred or joe
    • /\<the : Search the, theatre or then
    • /the\>: Search the or breathe
    • /\<the\> : Search 'the' (or search by * and #)
  • Basically projects have thousands of lines of code divided into hundreds or thousands of files.
  • In order to access various function definitions within the source code repository effectively using a Vim editor there is a great need for using add-ons which provides easy code go through.

 

Ctags

  • Ctags is a program that generates an index (or tag) file of language objects found in source files.
    • Functions, variables, class members, macros and so on could be indexed and saved in the tag file.
    • These tags allow definitions to be quickly and easily located by a text editor or other utility.
    • Supporting many programming languages.

 

Installing Ctags package

$ sudo apt-get install exuberant-ctags

 

Generating tags on your source code

$ cd /proj

$ ctags -R *

Finally include this single tag file as shown below in ~/.vimrc.

:set tags=~/proj/tags

 

Using Ctags in cursor position

  • Place the cursor on the first character of the function name and press the following keys:
    • CTRL+] : Jump to the file containing the definition of function name.
    • CTRL+t : Jump back to the previous location.

 

未命名  

arrow
arrow
    全站熱搜

    擒猿小舖 發表在 痞客邦 留言(0) 人氣()