gprof.vim 939 B

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