gprof.vim 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. " Language: gprof
  2. " Maintainer: Dominique Pelle <dominique.pelle@gmail.com>
  3. " Contributors: Doug Kearns <dougkearns@gmail.com>
  4. " Last Change: 2021 Sep 19
  5. " When cursor is on one line of the gprof call graph,
  6. " calling this function jumps to this function in the call graph.
  7. if exists("b:did_ftplugin")
  8. finish
  9. endif
  10. let b:did_ftplugin=1
  11. func! <SID>GprofJumpToFunctionIndex()
  12. let l:line = getline('.')
  13. if l:line =~ '[\d\+\]$'
  14. " We're in a line in the call graph.
  15. norm! $y%
  16. call search('^' . escape(@", '[]'), 'sw')
  17. norm! zz
  18. elseif l:line =~ '^\(\s*[0-9\.]\+\)\{3}\s\+'
  19. " We're in line in the flat profile.
  20. norm! 55|eby$
  21. call search('^\[\d\+\].*\d\s\+' . escape(@", '[]*.') . '\>', 'sW')
  22. norm! zz
  23. endif
  24. endfunc
  25. if !exists("no_plugin_maps") && !exists("no_gprof_maps")
  26. " Pressing <C-]> on a line in the gprof flat profile or in
  27. " the call graph, jumps to the corresponding function inside
  28. " the flat profile.
  29. map <buffer> <silent> <C-]> :call <SID>GprofJumpToFunctionIndex()<CR>
  30. let b:undo_ftplugin = "silent! unmap <buffer> <C-]>"
  31. endif
  32. " vim:sw=2 fdm=indent