ºìÁªLinuxÃÅ»§
Linux°ïÖú

Linuxϱà³Ì¸¨Öú¹¤¾ßvim+ctags+taglist+cppcomplete+cscope+global

·¢²¼Ê±¼ä:2007-08-16 15:47:08À´Ô´:ºìÁª×÷Õß:nsformat
¸÷¸ö¹¤¾ßµÄÖ÷Òª¹¦ÄÜ£º
vim£ºÕâ¸öÊÇLinuxϹ¦ÄÜÊ®·ÖÇ¿´óµÄ±à¼­Æ÷£¬¾Í²»ËµÁË¡£
ctags£ºÉú³ÉtagÎļþµÄÃüÁÕâ¸öÊÇÆäËü¹¤¾ßµÄ»ù´¡¡£
taglist£ºÐèÒªctagsµÄÖ§³Å£¬Ö±½ÓÔÚ×ó±ßÁгöº¯ÊýÁÐ±í£¬È«¾Ö²ÎÊýÁÐ±í¡£
cppcomplete£ºÐèÒªctagsµÄÖ§³Å£¬¿ÉÒÔ²¹È«ÀàÐÍ»òÕߺ¯ÊýÃû¡£
cscope£º±È½ÏÇ¿´ó£¬¿ÉÒÔ¶Ôº¯ÊýÒÔ¼°²¿·ÖÀàÐͶ¨Òå½øÐÐÌøת£¬ÆäʵcscopeÊÇÓÃÀ´Ìæ´úctags¹¦Äܵġ£
global£ºÃ²ËƺÍcscope£¬taglist¹¦ÄÜÒ»Ñù£¬¾Ý˵¶ÔÓÚ´óÐ͵Ť³Ì±íÏÖ²»´í¡£

¸÷¸ö¹¤¾ßµÄ°²×°£º
1£©vim£¬ctags£¬cscope£¬global£¬ÔÚϵͳ°²×°Ê±°²×°£¬»òÕßʹÓÃyum°²×°¡£
2£©ÏÂÔØvimµÄcscope²å¼þ£¬²¢·Åµ½ÏàӦĿ¼Ï£¬Èç~/.vim/plugin/

2£©taglist£¬cppcompleteÊÇVimµÄ²å¼þ£¬´ÓÏÂÃæµØÖ·»ñµÃ£¬È»ºó·Åµ½vimÏàӦĿ¼Ï¼´¿É¡£

¸÷¸ö¹¤¾ßµÄʹÓãº
1£©ctagsµÄʹÓÃ
ÔÚÖÕ¶ËÔËÐÐÈçÏÂÃüÁ½«Éú³ÉÎļþtags£º
ctags *.cpp
ÒªÉú³ÉcppcompleteÐèÒªµÄtagsÎļþµÄ»°£¬ÐèÒªÔËÐÐÏÂÃæµÄÃüÁ
ctags -n -f cppcomplete.tags --fields=+ai --C++-types=+p * -L cscope.files
×¢Ò⣬ÎÒÔÚ×îºóʹÓÃÁ˲ÎÊý"-L cscope.files" Õâ½ö½öÊǽèÓÃÀ­cscopeÉú³ÉµÄÎļþË÷ÒýÀ´°ïÖúctagsÈ¥²éѯÏà¹Ø¹¤³ÌÎļþÉú³Étags¡£

2£©Ê¹ÓÃtaglist
taglistµÄ¹¦ÄÜÊǼ´Ê±Éú³Éµ±Ç°ÎļþµÄº¯ÊýÁбíºÍÈ«¾Ö±äÁ¿ÁÐ±í£¬±ãÓÚË÷Òý¡£
ÔÚvimÖÐÃüÁîģʽÏÂʹÓãº
Tlist ´ò¿ª»òÕ߹رյ±Ç°ÎļþµÄË÷Òý£»
TlistSync Á¢¼´ÔÚ´ò¿ªµÄË÷Òý´°¿ÚÖж¨Î»µ±Ç°µÄ¹â±êËùÔÚλÖÃÊôÓÚÄĸöº¯Êý»òÕ߽ṹ¶¨ÒåÖС£

3£©Ê¹ÓÃcppcomplete
ʹÓúܼòµ¥£¬¾ÍÊÇÔÚÄãÐèÒª²¹È«ÀàÐͳÉԱʱ£¬°´F8¼ü¾Í¿ÉÒÔÀ²¡£
The default key mapping to complete the code are:

Alt+l in insert mode will try to find the possible completions and display them in a popup menu. Also normal completions to the names in cppcomplete.tags.
Alt+j in insert mode will show the popup menu with the last results. Selecting one of the items will paste the text.
F8/F9 will work in a similar way as Ctrl+N, Ctrl+P in unextended vim so the script can be used without the popup menu.
F5 in insert mode will lookup the class and display it in a preview window

The key mapping are only tested under Windows and linux and they will not work on all platforms. Changing the mappings is easy.

4£©Ê¹ÓÃcscope
cscopeµÄtagÉú³É×î¼òµ¥µÄ·½·¨ÊÇ£º
ÔÚÄãµÄ¿ª·¢¹¤³ÌµÄ×îÉϲãĿ¼ִÐÐcscope-indexer£¬Ëü»á±éÀúÏÂÃæµÄËùÓÐĿ¼£¬Éú³ÉÁ½¸öÎļþ£¬Ò»¸öÊÇcscope.files£¬Õâ¸öÎļþ¼Ç¼ÐèÒªÉú³ÉtagsµÄÎļþÃû£¬¿ÉÒÔÊÖ¹¤Ð޸ģ¬ÁíÒ»¸öÊÇcscope¸ñʽµÄtagsÎļþcscope.out¡£
Íê³Éºó£¬¾Í¿ÉÒÔʹÓÃCtrl-]Ìøת²éÕÒÀàÐͶ¨ÒåÁË¡£

5£©Ê¹ÓÃglobal
ÔÚ¹¤³ÌµÄ×îÉϲãĿ¼ִÐÐÃüÁ
gtags
µÈ´ýËüÍê³ÉËùÓÐÐèÒªµÄglobal×Ô¼º¸ñʽµÄtagsµÄÉú³É¡£Éú³ÉÍêºó£¬¿ÉÒÔÓÃÈçÏÂÃüÁî²éѯÏà¹ØÀàÐÍÒýÓú͹ØÁª¹Øϵ£º

Gtags xxxx ²éÕÒxxxxµÄ¶¨Òå
Gtags -r xxxx ²éÕÒxxxxµÄÒýÓÃ
Gtags -s xxxx ²éÕÒxxxx³öÏֵĵط½
ÓÐʱËüÎÞ·¨Õý³£·ÖÎöµÄÀàÐÍ ¿ÉÒÔÊÔÊÔÓôø-s µÄ²ÎÊýµÄ·½Ê½ÕÒÕÒÀàÐͶ¨Òå¡£
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 5 ÌõÆÀÂÛ

  1. jianxin_pan_00 ÓÚ 2011-11-20 00:02:53·¢±í:

    ºÜ²»´í ÕýÔÚÕÒ

  2. power1952 ÓÚ 2010-05-01 01:03:40·¢±í:

    ÕâЩ¸¨Öú¹¤¾ßÔØemacsÀïÃæÄܲ»ÄÜÓð¡?

  3. yeqishi ÓÚ 2010-04-30 09:17:25·¢±í:

    ¶¥£¬ÓÐЩÕýÔÚÓò»´í

  4. itofly2010 ÓÚ 2010-03-26 15:26:18·¢±í:

    ¿´ÁË»¹ÊDz»»á~

  5. otwett ÓÚ 2009-12-01 11:48:01·¢±í:

    ¾ÍÊÇÏëÕÒ¸öʹÓ÷½·¨ÁË