How to make vim show the current class and method I’m editing

text-editorsvim

Does anyone know if it's possible (or know of an existing vim script or plugin) that can create a "status bar" that shows the name of the current class and method (or function) I'm editing?

I'm imagining that it would plug into the syntax parser for the filetype of the current buffer, and display a breadcrumb trail to show you what you're currently editing. I don't know vimscript well enough to suggest any more than that, but if there aren't any good solutions already, I may begin to hack on one, so suggestions as to where to start are welcome, too!

Best Answer

This will work if you install both the airline and tagbar plugins. These two plugins integrate automatically and you'll get the current function displayed in the status bar. If you want to have the full object hierarchy (e.g. class + method), you'll have to configure that in your .vimrc:

let g:airline#extensions#tagbar#flags = 'f'  " show full tag hierarchy

You might have to setup the tags file for tagbar to identify the current code position, if you are not using ctags, yet. If you don't know about that yet, here's a short intro to ctags.

Related Question