0

You know how we can get information about the current file with Ctrl+g. I would like to extend that to show the current function name the cursor is currently in. Assume C language.

Any Vim pros out there to help me out?

3
  • You would like it to show the name of the function you're currently "in"? Or?
    – Rook
    Oct 14, 2011 at 18:48
  • vim mailing lists & irc is a better place to ask, I would say. Oct 14, 2011 at 19:15
  • @Idigas, yes, the function cursor is in, currently.
    – slowpoison
    Oct 14, 2011 at 19:24

2 Answers 2

1

map . :call getline(search("^[^ \t#/]\\{2}.*[^:]\s*$", 'bW')) <CR> %%b

then input . will show "the current function name the cursor is currently in"

0

You must really have large functions.

I see two ways to do that:

  1. by folding with the cursor on a blank line, it will fold the entire current function, letting you see its name. za to fold, look at the name, za to unfold.

  2. by using either TagList or TagBar, invoking either of these plugins will create a split window with an outline of your file and the cursor positioned on the current function's name and the name highlighted. If your cursor is on a member's name it will show the member instead so you may have to move your cursor over a keyword like int or on some whitespace.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .