List of all functions defined in the file

When editing a python file in vim;

What's a good way to get all the listed functions or classes plus the ability to go to the lines where they are defined?

+3


source to share


5 answers


Small "guide", but:

:g/def\ .*

      

will show you the lines, and in normal mode you can press <line number>gg

to go to that line.



Based on jan self found answer below:

Custom GJ Command (for GrepJump!)

command! -nargs=1 GJ vimgrep <q-args> % | copen

      

+3


source


Plugin TagList or Tagbar. You will need to install ctags or exuberant ctags .

Excerpt from mine .vimrc

:



Bundle "majutsushi/tagbar"
  nmap <script> <silent> <unique> <F4> :TagbarToggle<CR>

      

+1


source


Got it. If you use the command :vim

, your search is redirected to quickfixlist. Thus,

:vim /def\ ./ %
:copen

      

i.e. "do vim [grep] on the current file" and "open quickfix window" to go to the match will do the job.

+1


source


I like to use the weekthonfold fold method / class :

screenshot of vim editing session using jpythonfold

Not exactly what you asked for, but it does provide a nice display of classes, methods, and functions that you can move around quickly.

0


source


Assuming you are using ctags or whatever, the default :tag foo<Tab>

or command :tag <Tab>

may suffice, but you can get the tags from other files:

: tag foo <Tab>

:ilist def .*

- another solution. At the command prompt, enter :<Number><CR>

:

: ilist def. *

But I love CtrlP :CtrlPBufTag

:

: CtrlPBufTag

0


source







All Articles