Ctags 의 상세 한 사용 설명

  tags  ,shell   ctags -R
 vi       tags,:set tags=tags   :     tags    

vim+ctags  (  )

[/home/brimmer/src]$ ctags -R

"-R"      ,                      。"tags"    
        :

l  #define    

l        

l      、     

l     (namespace)

l     (typedefs)

l   (       )

l  (class)、  (struct)、    (enum)   (union)

l  、             

VIM   "tags"                ,               
:

1)     。   vim     "-t"  ,  :

[/home/brimmer/src]$ vim -t foo_bar

         "foo_bar"(        )   ,          。


2)  vim     ":ta"  ,  :

:ta foo_bar

3)                     ,    "Ctrl-]"。 "Ctrl-o"   
    。

  :  vim   ,   "tags"          。  ,  vim     
 ":set tags="    "tags"     ,  vim

    "tags"  。

        
[{            "{"

}]            "{"

{        

}        

gd                 

*                    

#                    

Vim              ,        Vim              :

               ;                。      

        。

*29.1*          ?
               。       C    C++         。  
              。Vim       

           ,              。            C 
        ,         : ctags

*.c"ctags"         。    Unix           。        
,        "Exuberant ctags":

http://ctags.sf.net                         : :tag st
artlist          "startlist",    

         。 CTRL-]                 。        
  C          。    ,      

"write_block"  。           "write_line"。  "write_line"     
 ?        "write_line"       

CTRL-],                 。 "write_line"       "write_ch
ar"。
          。         "write_char"        CTRL-],   
   "write_char"    。
+--+ |
void write_block(char **s; int cnt) | |
{ | | int i; | | for (i = 0; i < cnt; ++i)
| | write_line(s[i]); | |} | | +----|----+ | CTRL-] | | +-------+ +-->
|void write_line(char *s) | |{ | | while (*s != 0) | | write_char(*s++); | |} 
| | +-|-----+ | CTRL-] | | +-+ +--> |void

write_char(char c) | |{ | | putchar((int)(unsigned char)c); | |} |
+-+":tags"             : :tags # TO tag FROM line in file/text 1 
1 write_line 8 write_block.c 2 1 write_char 7

write_line.c >
        。 CTRL-T           。    ,     "write_line
"     "write_char"    。        

     ,             。       ,        。  
         。             

      : :tag                  。  :":3tag"。 CTRL-
T             。       ,  

   CTRL-]          ,   CTRL-T     , ":tags"         
。       ":tag"              

         。             ?      ":split"      
       ":tag"   。Vim         

    : :stag tagname                         : CT
RL-W ]         ,          

   。                       ,              
    。Vim              。  

    'tags'   ,              。   : :set tags=./tags,./.
./tags,./*/tags    Vim           

                 。             ,      。 
 ,    "~/proj/src"          , 

     "~/proj/sub/tags"         。     ,Vim         
           ,  : :set

tags=~/proj/**/tags             Vim             ,     
      。      。      ,  

                   。        。           
"Exuberant ctags"   。           

    : cd ~/proj ctags -R .       
"Exuberant ctags"           ,       C   C++  ,     Ei
ffel    Vim   。    ctags       

    。          Vim          : :set tags=~/proj/tags   
         (      )     ,
":tags"          。            ,         。   
                 : :tnext 

                。        ,            :

:tselect tagnameVim            : # pri kind tag file 1 F f mch_ini
t os_amiga.c mch_init() 2 F f mch_init

os_mac.c mch_init() 3 F f mch_init os_msdos.c mch_init(void) 4 F f mch_init os
_riscos.c mch_init() Enter nr of choice (

to abort):                 (    )。           
         。             

    : :tfirst        :[count]tprevious    [count]     :[count]
tnext    [count]     :tlast        

      ,[count]     。
                           。             
 : :tag write_         。 

        ,                。            
    ,                  

    。        Vim            。             "
block"    。    : :tag /block     

       :   。Vim         "block"            。
        "/"    Vim          

        。                。    ,        
  "write_"      : :tselect /^write_"^"

      "write_"   ,        "write_"          。   ,
"___FCKpd___0quot;            。
         CTRL-]                   ,          
          。
        。            (   Exuberant ctags): ctags --c-t
ypes=f -f functions *.c     Vim      

            : vim :vsplit functions              。
          。  ":setlocal ts=99"   

         。       ,     mapping: :nnoremap   
0yew:tag "。Vim                     。     
        'ignorecase'           

   。'tagbsearch'               。             ,
        ,              

  。'taglength'         Vim            。     SNiFF+  
  ,      Vim       |sniff| 。

SNiFF+        。Cscope        。                
  ,              。    

|cscope|。

---

*29.2*                  ,            。
         ,               。          。  
                 。     

       。               "write_char": :ptag write_charVim
        ,    "write_char"   。  

         。               CTRL-W   。         
   ,                   

 : CTRL-W }                   。    |CursorHold-exampl
e| 。            : :pclose    

            ,  ":pedit" 。           ,  : :pedit 
defs.h  , "psearch"             

                   。                   
。  : :psearch popen            

popen()     "stdio.h"   : FILE *popen __P((const char *, const char *));
      'previewheight'           

    。

---

*29.3*                  ,Vim            。
                 。 C               : #ifdef U
SE_POPEN fd = popen("ls", "r") #else fd =

fopen("tmp", "w") #endif      ,      。
      "#ifdef"    %。Vim     "#else"。    %      "#endif"。 
    %        "#ifdef"。       

,Vim          。             "#endif"     。
      "#ifdef" - "#endif"        ,              : 
[#          "#if"   "#ifdef"   ,

Vim    。
              "#else"   "#endif": ]#              
"#if" - "#endif"  。  : #if defined

(HAS_INC_H)
a = a + inc();
# ifdef USE_THEME
a += 3;
# endif
set_width(a);
         ,"[#"        。    "#ifdef" - "#endif"     。
             C        {}  ,  

       。             ,  "[["  。  "]["      。(
    "{"   "}"      。) "[{"     

          。          {}  。"]}"      。     : f
unction(int a) +-> { | if (a) | +-> { [[ | |

for (;;) --+ | | +-> { | | [{ | | foo(32); | --+ | | [{ | if (bar(a)) --+ | ]}
 | +-- | +-- break; | ]} | | | }  } | [] | int func2(void) | +-
> { | [[ | if (flag) start +-- +-- return flag;

| ][ | return 2; | +-> } ]] | | int func3(void) +---> { return 3; }      
    "%"      (), {}   []    。  

            。           "[("   "])"   "[}"   "]}"   ,
         ()      {}  。 [(  f)) && x > y) -------> ----> ])     
                  "[/";    

        "]/"。    /* - */     。 +-> +-> /* | [/ | * A comment a
bout --+ [/ | +-- * wonderful life. | ]/ | */

 vim.h -->
 
   "io.h"             。"vim.h"     ,   ":checkpath"   
              。        

"vim.h"     "functions.h"  "clib/exec_protos.h"   。
Note: Vim        。      "#ifdef"   。        "#include" 
       ,     "#if NEVER"   。
  'path'                      。        Makefile。
       "-I"    ,   "-

I/usr/local/X11"。
       , : :set path+=/usr/local/X11         ,     "*"
    。
  :
:set path+=/usr/*/include     "/usr/local/include"    "/usr/X11/include"
       。               

         ,"**"      。          。  : :set path+=/
projects/invent/**/include          

  : /projects/invent/include /projects/invent/main/include /projects/invent
/main/os/include etc.        。    

,    'path'   。
             ,     : :checkpath!      (  )   
    。      ,Vim          

  "(Already listed)"          。         "[I"         
       。              ,

          : [       "[ CTRL-I",    CTRL-I      
   。"[I"                 

 。               ,      : 3[          
 。       CTRL-O         。   

    [i          ]I            ]i              
               "[I"          

。    "#define"     , : [D  ,             。 'define
'      "[D"          。     

       C   C++      。 "[D"     : [d          ]D   
         ]d              

---

*29.5*        "[I"            。              
            , :
gD  :Goto Definition。         (C      "static")       
     。  (    "counter"  ): +->

static int counter = 0; | | int get_counter(void) gD | { | ++counter; +-- retu
rn counter; }           ,     

    ,     : gd                          。
   ,             '{'     

 ,             。  (     idx  ): int find_entry(char 
*name) { +-> int idx; | gd | for (idx = 0; idx

< table_len; ++idx) | if (strcmp(table[idx].name, name) == 0) +-- return idx; 
} 

좋은 웹페이지 즐겨찾기