Linux/vim

[vim] 임의 위치의 tags & cscope 추가

暻煥 2024. 9. 21. 14:38

 

다른 경로에 위치하고 있는 tags 및 cscope 파일을 참조 할 수 있도록 명령어를 추가한다,

 

vimrc 파일에 아래 내용을 추가한다,

function! Add_tags_cscope(path)
	echo "Add cscsope and ctags from " a:path

	let l:tmpstr = a:path . "tags"
	exe 'set tags+=' . tmpstr

	let l:tmpstr = a:path . "cscope.out"
	exe 'cscope add '. tmpstr . ' ' . a:path

	return
endfunction

" How to Use => :TagsAdd /x/y/z/
command -nargs=1 -complete=file TagsAdd :call Add_tags_cscope("<args>")

 

이제, vim의 command bar에서 아래 명령어로 사용 가능하다.

:TagsAdd /path/to/source/

 


※ 참고 및 출처

https://vimdoc.sourceforge.net/htmldoc/usr_40.html#40.2

 

Vim documentation: usr_40

 

vimdoc.sourceforge.net

https://learnvim.irian.to/vimscript/vimscript_functions

 

Vimscript Functions | Learn Vim

Vimscript Functions

learnvim.irian.to

 

.