[so] Fisiere tags

Cosmin Ratiu cosminratiu at gmail.com
Thu May 21 14:49:29 EEST 2009


Recomand cscope, e un pic mai avansat decat ctags.

Un script util pt cscope de adaugat in .bashrc:
<pre>
function gen-cscope
{
    find "${@:-.}" -iregex '.*\.\(c\|h\|cpp\|hpp\|cc\|hh\|cxx\|hxx\|py\)' |
cscope -b -i-
}
</pre>

Ce face? Cauta toate sursele cu extensiile alea si construieste baza de date
cu tag-uri din ele. De executat in radacina proiectului.
Apoi puneti-va asta in .vimrc:

<pre>
if has("cscope")
        " Look for a 'cscope.out' file starting from the current directory,
        " going up to the root directory.

        let s:dirs = split(getcwd(), "/")
        while s:dirs != []
                let s:path = "/" . join(s:dirs, "/")
                if (filereadable(s:path . "/cscope.out"))
                        execute "cs add " . s:path . "/cscope.out " . s:path
. " -v"
                        break
                endif
                let s:dirs = s:dirs[:-2]
        endwhile

        set csto=0
        set cst
        set csverb

        nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>
        nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>
        nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>
        nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR>
        nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR>
        nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
        nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
        nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>

        map <F10> :copen<CR>
        map <F11> :cprevious<CR>
        map <F12> :cnext<CR>

        " Open a quicfix window for the following queries.
        set cscopequickfix=s-,c-,d-,i-,t-,e-,g-
endif
</pre>

Ce face?
1) cand editati un fisier, cauta si incarca automat fisierul cu taguri
incepand cu directorul curent si continuand in sus.
2) multe scurtaturi utile (exemplu: Ctrl + \ urmat de s contruieste o lista
cu toate locatiile unde e folosit simbolul de pe cursor).

Cosmin.

PS: emacs sucks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cursuri.cs.pub.ro/pipermail/so/attachments/20090521/6debaddd/attachment-0001.htm>


More information about the so mailing list