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

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

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

张正宇
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?

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. And file D,E,F,G...


Thanks!
zzy

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

signature.asc (859 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

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

MarcWeber
<c-w> s then use :tjump or such -> you can write a mapping easily such
as :nnoremap <f3> <c-w>s:tjump<space>

Marc Weber

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Bryan Richter
In reply to this post by 张正宇
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

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

signature.asc (817 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

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

张正宇
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

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

signature.asc (859 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

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

张正宇


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

Thanks
zzy

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

signature.asc (859 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

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

Nicola
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

张正宇
Hi Nicola

On 9/28/16 6:33 PM, Nicola wrote:

>> On 9/22/16 2:28 PM, 张正宇 wrote:
>>
>> 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.
>
Thanks for your reply. It is never to late to know new things :)

My plugin is just a simple wrapper of something similar to preview
window - most of my want is a new window, isn't it? The rest is to
create a bidirectional flow between these windows.


All the best!
zzy

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

signature.asc (859 bytes) Download Attachment