Show function name in status line

后端 未结 7 587
感情败类
感情败类 2020-12-15 03:10

I edit a large C, C++, or Java file, say, about 15000 lines, with pretty long function definitions, say, about 400 lines. When the cursor is in middle of a function definiti

7条回答
  •  爱一瞬间的悲伤
    2020-12-15 03:40

    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() 
    

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

提交回复
热议问题