Ctags 의 상세 한 사용 설명
9732 단어 Linux 시스템 프로 그래 밍리 눅 스 운영 체제
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;
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Linux 명령 편의 finger 명령, id 명령 과 chage 명령리 눅 스 finger 명령 은 시스템 관리자 에 게 언제 얼마나 많은 사용자 가 이 리 눅 스 호스트 를 사용 하고 있 는 지 알 수 있 는 방법 을 제공 합 니 다. 이 간단 한 명령 에 대해 서 는 먼저 소개 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.