Show function name in status line

To show current function name in C programs add following in your vimrc:

fun! ShowFuncName()
  let lnum = line(".")
  let col = col(".")
  echohl ModeMsg
  echo getline(search("^[^ \t#/]\\{2}.*[^:]\s*$", 'bW'))
  echohl None
  call search("\\%" . lnum . "l" . "\\%" . col . "c")
endfun
map f :call ShowFuncName() <CR>

Or if you need the "f" key, just map the function to whatever you like.


You can use ctags.vim for this, it will show the current function name in the title or status bar.

SOURCE: https://superuser.com/questions/279651/how-can-i-make-vim-show-the-current-class-and-method-im-editing

Tags:

Vim