Readability of source code is decreasing when project is getting bigger. The aim of this tool is to make code more easily readable and understandable. In other words it is trying to put big projects more under control.
Normally readability of long single function is preserved by using indentation of code lines. This plugin provides kind of indentation at higher level - indentation of whole functions.
User can see fairly easily how current function is dependent upon others. He will also get structure of all functions in code in a tree layout if code is clearly implemented. So therefor Code Upstairs is also kind of quality controller.
Code Upstairs is a programmer editors plugins.
Unpack cu-vim-VERSION.tgz
and the content of extracted code_upstairs-VERSION
directory move
to your ~/.vim/
or whole directory to Pathogen corner.
Current version Code Upstairs works only with C and Python.
For C you need to have installed cscope
and
for Python you need cscope
along with pycscope
Vim has to be compiled with python
support.
Open some file of your project and call:
:CUinit <directory>
where <directory>
is the root of your project.
If skipped current directory will be used.
Statusline will appear if it was disabled, and you can see functions structure there, but only when cursor is in some function body.
To turn off Code Upstairs use:
:CUshutdown
Functions structure is shown in statusline. Because of limited space statusline is divided to layers. Following layers are shown in order from left to right:
- (-) layer showing original vim statusline (like filename and cursor position)
- (P) layer with parents of current function. Parent is a function from which current function is called.
- (S) siblings layer shows functions which are on the same level with current function looking from parent perspective (Frankly saying siblings are pure child functions of parent function, check out next layer!)
- (C) children layer shows pure child functions of current function. Pure child function is a function which is called only from one parent.
- (XX) (where
XX
is a number) layer shows children functions in distanceXX
from current function. Those are not pure child functions, they have more than one parent and therefore theirs calls are distributed over code. DistanceXX
tells how far they are distributed. Further functions distances can mean not clear implementation or code design.
Default keybindings can be change using variables given in parenthesis.
<space>.
and<space>,
will switch layer forward and backward. (CUkeyNextLayer
andCUkeyPrevLayer
)<space>m
and<space>n
will switch function in a layer forward and backward. (CUkeyNextFunction
andCUkeyPrevFunction
)<space>b
will jump to function definition (CUkeyJumpToFunction
)<space>v
will jump back (CUkeyJumpBack
)<space>/
will highlight function name in vim window (CUkeyHighlightFunction
)
As for today Vim plugin is the only one which (somehow) works... Plugins for Gedit and Geany are under development. They are graphical widgets, so should be much more user friendly.