xref: /vim-8.2.3635/runtime/ftplugin/gprof.vim (revision 89a9c159)
1" Language:    gprof
2" Maintainer:  Dominique Pelle <[email protected]>
3" Last Change: 2021 Apr 08
4
5" When cursor is on one line of the gprof call graph,
6" calling this function jumps to this function in the call graph.
7if exists("b:did_ftplugin")
8  finish
9endif
10let b:did_ftplugin=1
11
12fun! <SID>GprofJumpToFunctionIndex()
13  let l:line = getline('.')
14  if l:line =~ '[\d\+\]$'
15    " We're in a line in the call graph.
16    norm! $y%
17    call search('^' . escape(@", '[]'), 'sw')
18    norm! zz
19  elseif l:line =~ '^\(\s*[0-9\.]\+\)\{3}\s\+'
20    " We're in line in the flat profile.
21    norm! 55|eby$
22    call search('^\[\d\+\].*\d\s\+' .  escape(@", '[]*.') . '\>', 'sW')
23    norm! zz
24  endif
25endfun
26
27" Pressing <C-]> on a line in the gprof flat profile or in
28" the call graph, jumps to the corresponding function inside
29" the flat profile.
30map <buffer> <silent> <C-]> :call <SID>GprofJumpToFunctionIndex()<CR>
31
32" vim:sw=2 fdm=indent
33