Bram Moolenaar | 543b7ef | 2013-06-01 14:50:56 +0200 | [diff] [blame] | 1 | " Language: gprof |
| 2 | " Maintainer: Dominique Pelle <dominique.pelle@gmail.com> |
| 3 | " Last Change: 2012 May 20 |
| 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. |
| 7 | if exists("b:did_ftplugin") |
| 8 | finish |
| 9 | endif |
| 10 | let b:did_ftplugin=1 |
| 11 | |
| 12 | fun! <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|y$ |
| 22 | call search('^\[\d\+\].*\d\s\+' . escape(@", '[]*.'), 'sW') |
| 23 | norm zz |
| 24 | endif |
| 25 | endfun |
| 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. |
| 30 | map <silent> <C-]> :call <SID>GprofJumpToFunctionIndex()<CR> |
| 31 | |
| 32 | " vim:sw=2 fdm=indent |