vim

Fork of vim, an acceptable text editor
git clone git://git.laack.co/vim.git
Log | Files | Refs | README | LICENSE

gprof.vim (1120B)


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