Jump to function definition in vim

后端 未结 11 2662
独厮守ぢ
独厮守ぢ 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:49

    As Paul Tomblin mentioned you have to use ctags. You could also consider using plugins to select appropriate one or to preview the definition of the function under cursor. Without plugins you will have a headache trying to select one of the hundreds overloaded 'doAction' methods as built in ctags support doesn't take in account the context - just a name.

    Also you can use cscope and its 'find global symbol' function. But your vim have to be compiled with +cscope support which isn't default one option of build.

    If you know that the function is defined in the current file, you can use 'gD' keystrokes in a normal mode to jump to definition of the symbol under cursor.

    Here is the most downloaded plugin for navigation
    http://www.vim.org/scripts/script.php?script_id=273

    Here is one I've written to select context while jump to tag
    http://www.vim.org/scripts/script.php?script_id=2507

提交回复
热议问题