Passion/Programming

vi + ctags + cscope 사용하기

sunshout 2013. 3. 28. 16:43

1.   [Devel] Vi + C + cscope + ctags

 

커널 개발의 최고 조합은 vi + c + cscope + ctags 라고 보면 된다.

 

¡ 설치

apt-get install ctag (for ubuntu)

yum install ctags  (for centos,redhat)

 

¡ ctags 사용법

 

ctags DB 만들기 : 분석할 소스에서 ctags -R

victags DB가 있는 위치에서 실행해야 함

(또는 .vimrc 에  set tags+=/<태그 폴더>/tags 추가)

 

단축키

설명

ctrl + ]

커서가 있는 함수나 구조체의 정의로 이동

ctrl + t

이전 위치로 돌아옴

:ta [keyword]

Keyword 위치로 이동

:tn

다음 태그로 이동(tag next)

:tp

이전 태그로 이동(tag previous)

Tags

이동한 태그 히스토리 출력

 

 

¡ cscope 사용법

 

:cs add <cscope db 파일>

:cs help

:cs find <검색유형> <keyworld>

 

검색 유형

설명

0 (s)

Symbol 을 검색

1 (g)

Global definition

2 (d)

Called by this function

3 (c)

Calling this function

4 (t)

Text string

5 (e)

Egrep pattern

6

 

7 (f)

Find name

8 (i)

#including this file




set tabstop=4
set shiftwidth=4
set visualbell
syntax on
set exrc
highlight Comment ctermfg=green

if filereadable("./cscope.out")
cs add cscope.out
endif

linux directory 밑에 .exrc
" Linux coding style"
set ts=8
set sw=8 
set sts=8
set noet