Improved jumps to definition
Asked Answered
P

1

9

When we're using ctags in vim and want to go to particular definition of variable or function we press ctrl + ], when we want to go back we press ctrl + T.

When we want to autocomplete a name of a variable we press ctrl + N and from a little violet window we can choose the right word.

Is it possible to improve go to definition so that we won't jump in the document, but only the little window with the function or variable definition will appear?

thank you

Prerecord answered 6/11, 2011 at 11:3 Comment(6)
Are you looking for :set completeopt+=preview?Orthotropous
@RandyMorris I tried it but don't have a feeling that this option do something with go to definition when I press ctrl + ]Prerecord
Try Ctrl-W followed by } instead of Ctrl-].Orthotropous
@RandyMorris This is opening another split window, not the small balloon as is in romainis answer.Prerecord
Balloons are not possible in console vim.Orthotropous
@RandyMorris By balloons I mean the same window that appears when you type ctrl+N while doing autocompletion.Prerecord
R
2

You want a way to see the function's signature without actually jumping to its definition?

I know about two plugins supposed to provide exactly this feature:

The last time I tried echofunc it didn't work for JavaScript, at least for me, but it worked well for the few PHP files I've tested it with. I didn't try the other one because it's GVim-only and I use the CLI version almost as often as the GUI version.

But you can also use TagList and/or TagBar: two very useful plugins providing great code navigation based on ctags. Both will display the signature of the tag under your cursor if you hit <Space>.

Russellrusset answered 6/11, 2011 at 12:34 Comment(4)
Thank you, it's on a good way, but I'm using only CLI version of vim and most of the time work with Python, C, Javascript. It should show the whole function definition when I move the cursor above function call (if the function is not too large). But the scripts you're suggesting look good and I will study them if nothing better exists yet.Prerecord
If you use tags to navigate through your code, there is a good page on the Vim wiki you will find interesting. Especially the "How do I preview a tag?" part.Russellrusset
@romaini I'd like to see the preview in the same window which appears during autocompletion when pressing ctrl+N. It works in CLI vim and disappears quickly when you start typing.Prerecord
I'm afraid I don't know a way to show that popup menu outside of omni-completion context: all the tools I know that show signatures use either a message in the command line or a small preview window with the exception of the "balloon" plugin. The most effective ways to show the signature of a function are IMO the <Space> trick in TagList/TagBar or the built-in <C-w>} has indicated by Randy Morris.Russellrusset

© 2022 - 2024 — McMap. All rights reserved.