Ctags簡單教學

       這篇利用vim來使用Ctags來找尋相關的Symbols和Function等等的教學。

References site : http://ctags.sourceforge.net/ctags.html#HOW TO USE WITH VI





1.  Create Project Directory
     
      http://hamisme.blogspot.com/2011/02/cscope.html 請參考這篇文章

2.  Create Reference file
      
     $ cd $HOME/xf86-video-intel-2.14.0
     $ ctags -R  $HOME/xf86-video-intel-2.14.0/xf86-video-intel-2.14.0/src/
     
     P.S. 這會在$HOME/xf86-video-intel-2.14.0底下產生tags的檔案來讓vim當作參考的檔案

3.  Use Vim Editor
     
     $ vim $HOME/xf86-video-intel-2.14.0/xf86-video-intel-2.14.0/src/intel_video.c
     
     P.S. 進入vim之後,可以隨便找個function或symbol,然後按Ctrl+]可以找到原本function或symbol的位置,如果是要返回原來的位置就按Ctrl+t就可以了。


HOW TO USE WITH VI

Vi will, by default, expect a tag file by the name "tags" in the current directory. Once the tag file is built, the following commands exercise the tag indexing feature:

vi −t tag
Start vi and position the cursor at the file and line where "tag" is defined.
:ta tag
Find a tag.
Ctrl-]
Find the tag under the cursor.
Ctrl-T
Return to previous location before jump to tag (not widely implemented).




留言

熱門文章