How to change the preview result position of vim's taglist plugin (hitting 'p')

StackOverflow https://stackoverflow.com/questions/19243729

  •  30-06-2022
  •  | 
  •  

質問

While using a preview [p] or jump-to [enter] command in the taglist window, the appropriate line is by default in the file-edit window. Because I mostly need to see more of what's right after the selected tag (functions), I'd love to change the line at which the tag is displayed from the center to let's say 1 third of the current page size (number of lines) or even to an explicit line (let's say 10th line from the top).

Is there a command/settings that would adjust the displayed position of a selected tag? (I couldn't find one in the manual).

Thanks

役に立ちましたか?

解決 3

Well, regarding the Ingo Karkat's comment, I managed to locate the appropriate line in the taglist plugin (begginning at line 3357, version 4.6):

" Jump to the tag
if a:tagpat != ''
    " Add the current cursor position to the jump list, so that user can
    " jump back using the ' and ` marks.
    mark '
    silent call search(a:tagpat, 'w')

    " Bring the line to the middle of the window
    normal! z.

    " If the line is inside a fold, open the fold
    if foldclosed('.') != -1
        .foldopen
    endif
endif

Here the part normal! z. needs to be changed appropriately to something that would change a position of the selected line appropriately. As I'm no vim-plugin guru, I changed it in the most dumb way possible as

" Bring the line to the middle of the window
normal! zt
normal! 10k
silent call search(a:tagpat, 'w')

which just walks 10times up and than searches the right position again. Hope this might help someone who 'struggles' with the same issue at the moment until a better solution is suggested or Yegappan Lakshmanan, the author, includes this (or rather something nicer) to his plugin (in case he decides to do that of course :) )

他のヒント

You're presumably looking for the zt (redraw with current line at the top of the window), and zz (redraw at center) commands, or something in between (which can be achieved with <C-Y> / <C-E> after those commands).

How to incorporate that into the plugin is best discussed with the plugin's author. Since you've found no configuration setting for this, you likely have to directly modify the source code. Write your suggestion to the author; you may get a configuration / hook for this in the next plugin version, or tips how to do this, or maybe the author's opinion of why this is a bad idea.

You could try to tweak the scrolloff setting. I don't know the tagbar plugin but I imagine setting :set so=5 should provide you some context when jumping around.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top