2015/05/05: Getting an overview over a large source file

Many editors have some form of support to give an overview over the top-level structure (e.g., classes and methods) of a source file. At least in well-formatted sources, this structure is also represented in by the indentation of the individual lines; some programming languages (like Python) even require this for the program to be correct at all. Therefore, getting an overview can be more uniform than it seems. The more I try various such approaches, the more I like one provided by traditional ed. For Python, a simple


g/^class \|^  def /n

shows only the back bone of the source file, together with line numbers allowing convenient digging deeper. (Depending on your coding conventions, the number of spaced needed may vary.) This work very nice, at least if your terminal is tall enough; using a multi-column termnial can help.

And in the worst case, you can focus on the structure by first removing everything else,


v/^class \|^  def /d

viewing the file part by part as usually, and finally undoing the removal.