From 61aabbe40d782af5ee9af8d0b2295950aa1afeaa Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Wed, 19 Oct 2011 15:24:23 +0200 Subject: [Vim] cscope power --- vimrc | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/vimrc b/vimrc index 8d2cfae..3416a55 100644 --- a/vimrc +++ b/vimrc @@ -81,6 +81,21 @@ autocmd BufReadPost * \ exe "normal zz" | \ endif +function! CscopeSearch(csearch) + + let @/=a:csearch + set hls + + let l:prompt = "Rechercher '".a:csearch."' avec cscope [cdefgist] : " + + echo l:prompt + let l:ctype=nr2char(getchar()) + redraw + echo l:prompt.l:ctype." " + + return 'set hls | cscope find '.l:ctype.' '.a:csearch +endfunction + " Load local cscope db if exists if filereadable( expand("$PWD/tags") ) set tags=tags @@ -89,18 +104,17 @@ elseif filereadable( expand("$PWD/ctags.out") ) elseif has("cscope") if filereadable( expand("$PWD/cscope.out") ) set cst + cscope add $PWD/cscope.out + " cscope macros - map :cs find g =expand("") " find global definition - map :cs find c =expand("") " find callers of function under cursor - map :cs find t =expand("") " find assignments to variable under cursor - map :cs find s =expand("") " find string under cursor - map :cs find f =expand("") " find file under cursor - map :cs find i =expand("") " find files including file under cursor - map :cs find I % " find files including current file - cs add $PWD/cscope.out + nmap c :execute CscopeSearch(expand("")) + nmap f :execute CscopeSearch(expand("")) + nmap % :execute CscopeSearch(expand("%:t")) + nmap r :execute CscopeSearch(input("Rechercher : ")) endif endif + " F*cking trailing whitespaces autocmd BufRead * highlight ExtraWhitespace ctermbg=red guibg=red autocmd BufRead * match ExtraWhitespace /\s\+$\| \+\ze\t\| / -- cgit v1.2.3