Maxim
Maxim

Reputation: 1803

Inspecting source code with vim, ctags and other tools

There is plenty of information about how to browse source code with vim/ctags, like jumping to a tag, navigating tag stack, searching for a tag match, etc.

However, I can't find information about how to actually inspect source code and its structure, similar to something like "source browser" tool in some IDEs.

The following is what I want to be able to do with Python source code using vim, though the same may be equally true for some other languages:

  1. List all members of the current file (module), i.e. top level classes, functions and/or variables defined in the module.
  2. List all methods and attributes of a given class.
  3. Jump to a member within a given class, i.e. something like :tag ClassName.my_method.
  4. List package members/hierarchy.

Upvotes: 3

Views: 1838

Answers (2)

Theo Belaire
Theo Belaire

Reputation: 3020

Have you looked at Rope?

http://rope.sourceforge.net/ropevim.html

Features

Rope refactorings:

  • Rename anything!
  • Extract method/local variable
  • Move class/function/module/package/method
  • Inline method/local variable/parameter
  • Restructuring (like converting "${a}.f(${b})" to "${b}.g(${a})" where "a: type=mymod.A")
  • Introduce factory
  • Change method signature
  • Transform module to package
  • Encapsulate field
  • Replace method with method object
  • And a few others...

Rope can:

  • Extract similar statements in extract refactorings
  • Fix imports when needed
  • Preview refactorings
  • Undo/redo refactorings
  • Interrupt refactorings
  • Perform cross-project refactorings
  • Handle basic implicit interfaces in rename and change signature
  • Support Mercurial, GIT, Darcs and SVN in refactorings

Rope can also help IDE's with:

  • Auto-completion
  • Finding definition location
  • Getting pydoc
  • Finding occurrences
  • Organizing imports (removing unused and duplicate imports and sorting them)
  • Generating python elements

http://rope.sourceforge.net/index.html

Upvotes: 1

romainl
romainl

Reputation: 196596

Some of what you want (the "listing" part, at least) can be done with TagList or TagBar but I'm afraid you are confusing Vim with an IDE.

Upvotes: 2

Related Questions