Reputation: 42852
If the cursor is in somewhere within a very long function, is there a way to let Vim tell the user in which function he/she is editing?
By the way, I use taglist but seems that taglist does not auto update where you are even if you have moved the cursor to a different function.
Upvotes: 1
Views: 438
Reputation: 72726
As an addition to Habi's answer, if you want to do it without using taglist, you can quite easily define a function that will work it out. It depends what language you're programming in, but for C-like languages, you can do this:
nmap ,f call ShowFuncName()
" Show the name of the current function (designed for C/C++, Perl, Java etc)
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
Put that it in your vimrc and then press ,f to see the current function.
Taken from here.
Upvotes: 3
Reputation: 3300
The taglist plugin provides this feature. The function in which the cursor is currently positioned is highlighted automatically in the list of functions of taglist.
Make sure that Tlist_Auto_Highlight_Tag is not equal 0 to enable this feature.
'updatetime' defines the time of no activity which must elapse before taglist highlights the current function. Default is 4 seconds.
:help taglist.txt See section "Highlighting the current tag"
As a quick test: Type :TlistHighlightTag to force taglist to highlight the current function. If this works I suppose that you have disabled the automatic highlighting in any way (see Tlist_Auto_Highlight_Tag).
Upvotes: 5