1

Note: I may totally be using "window" and "buffer" incorrectly here.

When jumping up/down a callstack, would like to look at both the callsite, and the called-function at the same time, in different windows.

I know I can always open a new preview window when jumping to a tag - but I find this creates a lot of windows quick.

I think what I want to do, is either:

  • Specify an existing window to open the tag in (ex. window to the left, right, ect)
  • Simply "save-off" a buffer by showing the same buffer in another existing window.

I'm also open to better ideas

Thank you

1

For following tags, you basically have three options:

  • in the same window, replacing the current buffer :tag
  • in a split window :stag; this will create many new windows, to you need to clean up / minimize
  • in the preview window :ptag; there's only one preview window per tab page, so this self-manages the windows for you; however, if you further navigate inside the preview window, further tag jumps effectively become same-window, i.e. :ptag is equivalent to :tag.

You can build your workflow from there. One idea that's occurring to me as I write this would be a custom :AlternateTag command that performs :ptag when in a normal window, but re-assigns the preview window to another window is already in the preview window. This would allow you to toggle between two windows for tag lookups.

:command! -bar -count -bang -complete=tag -nargs=? AlternateTag if &previewwindow && winnr('$') && winnr('#') > 0 | setlocal nopreviewwindow | call setwinvar(winnr('#'), '&previewwindow', 1) | endif | <count>ptag <args>
| improve this answer | |
  • Awesome dude! Thanks! Random question: how would you call ptags with current word? I.e. :ptags <cword> searches for <cword> tag – anon Nov 14 '16 at 7:45
  • Glad I could help. To use the current word, use :execute 'ptags' expand('<cword>') – Ingo Karkat Nov 14 '16 at 7:51
  • I guess its something else: nmap <silent> <c-s-i> works fine, but changing the last part to <c-s-]> makes it do nothing? – anon Nov 14 '16 at 8:08
  • <C-}> should be the same as <C-]>, Vim currently cannot distinguish between the shifted and unshifted variant if it involves Ctrl and non-alphabetic keys. – Ingo Karkat Nov 14 '16 at 9:04
  • Ah crap - oh well! Well, thank you so much for answering my questions! Youre the best! – anon Nov 14 '16 at 11:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.