Vim + Ctags 更新

由于开发时常常使用Ctags进行跳转查询,因此特意写了一个函数用于更新ctags

代码:

“递归查询父文件夹的tags文件,这样在项目的那个文件夹当中就都可以访问同一个tags文件了

set tags=tags;

“更新ctags,找寻父文件夹原有tags文件

function UpdateCtags()
    let curdir=getcwd()
    while !filereadable(“./tags”)
        cd ..
        if getcwd() == “/”
            break
        endif
    endwhile
    if filewritable(“./tags”)
        !ctags -R –c++-types=+px –excmd=pattern –exclude=Makefile –exclude=.
    endif
    execute “:cd ” . curdir
endfunction

“映射键盘上的F10对应更新tags

nmap <F10> :call UpdateCtags()<CR>

自己用着挺爽……嘿嘿

This entry was posted in vim and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

Note: Commenter is allowed to use '@User+blank' to automatically notify your reply to other commenter. e.g, if ABC is one of commenter of this post, then write '@ABC '(exclude ') will automatically send your comment to ABC. Using '@all ' to notify all previous commenters. Be sure that the value of User should exactly match with commenter's name (case sensitive).

This site uses Akismet to reduce spam. Learn how your comment data is processed.