Wednesday, September 28, 2016

Re: vim & ctags: how to jump to the definition in new window

On 2016-09-28 08:26:47 +0000, 张正宇 said:

>
>
> On 9/22/16 2:28 PM, 张正宇 wrote:
>> Hi Bryan & Marc
>>
>> On 9/21/16 9:30 PM, Bryan Richter wrote:
>>> On Wed, Sep 21, 2016 at 10:49:48AM +0800, 张正宇 wrote:
>>>> Hello list!
>>>>
>>>> I am reading some source code with vim & ctags these days. You know
>>>> sometimes people just forget those input/output parameters while
>>>> diving into functions ...
>>>>
>>>> So, is there some good way to open a new window to view the
>>>> definition after I press 'G+] ' while keep the previous file shown?
>>>
>>> The split version of 'g ]' is 'CTRL-W g ]'. The commands versions of
>>> those keybindings are :tselect and :stselect.
>>>
>>>> All I want is a 'Cover Flow' style. For example, after I press 'G+]'
>>>> in file A, a new window split up from A's to show file B. When I
>>>> press 'G+]' again in file B, file A is hidden and replaced by B,
>>>> while a new file C will show up in B's former window.
>>>
>>> Here's a sample workflow. It could be made easier with some custom
>>> commands...
>>>
>>> " Begin with a fresh tab page while in file A
>>>
>>> :tab split
>>>
>>> " Split and view a definition.
>>>
>>> CTRL-W g ]
>>>
>>> " Now A and B are visible. From file B, jump further forward.
>>>
>>> :only
>>> CTRL-W g ]
>>>
>>> " Further... (C and D become visible)
>>>
>>> :only
>>> CTRL-W g ]
>>>
>>> " Now backwards! (B and C are visible again)
>>>
>>> :only
>>> :below split
>>> :pop
>>>
>>> " ...
>>> "
>>> " Leave the 'Cover Flow' view
>>>
>>> :tabclose
>>>
>>
>>
>> Thanks for your reply. `Ctrl-W g ]` seems to be a good start. I will do
>> some homework on vim and try to figure out my own 'cover flow' solution
>> (maybe learn to write a shabby plugin script? :P)
>>
>>
>> Thanks!
>> zzy
>>
>
> As I said, I struggled to write a plugin. Request for comment!
>
> https://github.com/freemandealer/CodeCoverFlow

You've brilliantly solved your own problem, so this may be a bit late, but…
using the commands and mappings described in :h preview-window might get
you close to your workflow. Off the top of my head, assuming you start from
a single window:

:ptag or <c-w>} or <c-w>g} (to open a tag in the preview window)
<c-w><c-x> (to exchange windows)
:se nopreviewwindow (to turn the preview window into a normal window)
<c-w><c-o> (to close the other window)

and repeat.

Nicola


--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: