Jump to function definition in vim

后端 未结 11 2607
独厮守ぢ
独厮守ぢ 2020-11-27 08:53

How can I jump to to a function definition using vim? For example with Visual Assist, I can type Alt+g under a function and it opens a context menu lis

11条回答
  •  春和景丽
    2020-11-27 09:38

    1- install exuberant ctags. If you're using osx, this article shows a little trick: http://www.runtime-era.com/2012/05/exuberant-ctags-in-osx-107.html

    2- If you only wish to include the ctags for the files in your directory only, run this command in your directory:

    ctags -R
    

    This will create a "tags" file for you.

    3- If you're using Ruby and wish to include the ctags for your gems (this has been really helpful for me with RubyMotion and local gems that I have developed), do the following:

    ctags --exclude=.git --exclude='*.log' -R * `bundle show --paths`
    

    credit: https://coderwall.com/p/lv1qww (Note that I omitted the -e option which generates tags for emacs instead of vim)

    4- Add the following line to your ~/.vimrc

    set autochdir 
    set tags+=./tags;
    

    (Why the semi colon: http://vim.wikia.com/wiki/Single_tags_file_for_a_source_tree )

    5- Go to the word you'd like to follow and hit ctrl + ] ; if you'd like to go back, use ctrl+o (source: https://stackoverflow.com/a/53929/226255)

提交回复
热议问题