Vim进入功能开始

时间:2018-07-14 09:42:03

标签: vim

我想使用;;转到c语言函数开始。

例如。

void helloworld() {
}

void helloworld2()
{
}

如果使用[[,则无法跳过helloworld函数,[M[m[{也不完美。

所以我在~/.vimrc中添加了nmap

fun! GetFuncBLine()
    let num = search("^[^ \t#/]\\{2}.*[^:]\s*$", 'bW')
endfun
nmap <silent> ;; :call GetFuncBLine() <CR>

使用此;;时,函数开始行无法推送至vim跳转列表,因此CTRL+oCTRL+i将无用

我疯了

1 个答案:

答案 0 :(得分:0)

.vimrc:

fun! JumpFuncName()
  let lnum = line(".")
  execute "normal " . lnum . "G<CR>"
  execute "normal \<C-O>"

  let num = search("^[^ \t#/]\\{2}.*[^:]\s*$", 'bW')
  execute "normal " . num . "G<CR>"
  execute "normal \<C-O>"
endfun
nmap <silent> [[ :call JumpFuncName() <CR>