Is there a way in vim to get a popup window with function parameters? (like in visual studio / slick edit)
e.g. when i type "function_name(" vim will open a popup window (like when doing ctrl-n in new versions) and show me the function parameters and which one of them I'm currently typing.
p.s.
I'm looking for something a bit more comfortable than ctrl-w ctrl-]
I'm also looking for a similar functionality that will show me list of available members when typing "var->" or "var."
I'm using C
Do check out the autocomplpop and TTrCodeAssistor plug-ins.
As was already suggested, install the autocomplpop plugin. Then,
to trigger omincompletion as you type for C files, you could add the following to your .vimrc:
let g:AutoComplPop_Behavior = {
\ 'c': [ {'command' : "\<C-x>\<C-o>",
\ 'pattern' : ".",
\ 'repeat' : 0}
\ ]
\}
If you don't want to trigger omnicompletion for every character typed, change the pattern value to suit your needs. For information on how to further customize, look at the documentation in the comment header of autocomplpop.vim
Moreover, to get a popup window with function parameters also add the following to your .vimrc:
let g:AutoComplPop_CompleteoptPreview = 1
To make it work make sure you generated a tags file with ctags.
YouCompleteMe is a nice alternative that offers fuzzy autocompletion and uses clang to deal with the semantics.
Check cream - it seems to have some C support. You'll need ctags.
A modern configuration of the powerful and famous Vim, Cream is now available for Microsoft Windows, GNU/Linux, and FreeBSD
... (Programmer Features)
Pop up prototype and information menu ( Alt+( ). View the function's prototype under the cursor without having to open the file with the definition.
Or you can try vim-assistant script.
Related
Im using vim with ctag+tagbar plugin to navigate through kernel code and its amazing ! Thanks to a guide I saw here.
I read here about some nice shortcuts for ctags that helps a lot, but I couldnt find a way that a definition(of structs/function etc) would show in popup box - something like eclipse ide.
Is there a way to do so with ctag? is there a plug-in I can add to vim that would that ? so when the mouse cursor(or also keyboard cursor) on function a popup box next to it will show?
Thanks!
Generally, you should avoid trying to use Vim as an IDE. It's meant to be a modular text editor.
Having said that, if you are looking for eclipse functionality inside of Vim, you may want to consider eclim. Another good set of plugins are the Clang based tools, like clang-format and YouCompleteMe.
ctags is very useful plugin, but if you also use ctags you can then copy file http://cscope.sourceforge.net/cscope_maps.vim to your ~/.vim/plugin directory and this will add keymappings that will allow you to jump to definition or show it in horizontal or vertical split.
I also added to my cscope_maps file an extra set of mappings like so:
nmap <C-h>g :tab cs find g <C-R>=expand("<cword>")<CR><CR>
to open my search in a new tab.
Example above allows you to use Ctrl+h and then g to "find global definition(s) of the token under cursor" and open it in a new tab.
Consider using cscope- it can also work with ctags (I always use both).
I know that this is not a pop-up window, but vim is not an IDE.
Eclipse has a feature (under Ctrl+O) that lets you choose a method or a variable, with autocompletion.
I am aware of the tagbar plugin for Vim but I'm looking for something that would show a pop-up (similar to what Eclipse does) and be able to get me to certain method after I choose it.
No need for plugins, that is built into vim.
You could do , that's CTRL+X followed by
: File completion
: Line completion
: Omni completion
: Dictionary completion
You could customise the pop-up window the way you like.
The 'complete' option controls where the keywords are searched
(include files, tag files, buffers, and more).
The 'completeopt' option controls how the completion occurs (for
example, whether a menu is shown).
See for details: http://vimdoc.sourceforge.net/htmldoc/options.html#'completeopt'
This is the usual workflow:
Index your project with ctags, cscope or some compatible program. Using ctags as an example:
$ ctags -R .
Query that index from Vim:
:tselect /expan
Choose from the list:
Note that Vim also comes with a more lightweight solution:
:dlist /foo
that will search through the current buffer and included files for foo.
The plugin which has the functionalities I was looking for is ctrlp-funky.
It works only with functions and methods but its enough for my needs and works with every language without having to configure anything (like ctags/cscope).
I used Jedi-vim for vim python auto-completion and it works well. It has shortcut to show preview/documentation of a function on demand.
I'm working on C++ projects now and I'm trying to use original omnicomplete+ctag to accomplish the same thing. But I can't find functions similar to in Jedi-vim.
I don't want to show preview window all the time by doing ":set completeopt+=preview", and I don't want to use huge autocompletion plug-in like "YouCompleteMe", I just simply want to open/jump to preview on demand. Is there any way to accomplish it? Thanks in advance!
I think you will find :help preview-window interesting.
" shows the definition of foo in the preview window
:ptag foo
" shows the definition of the symbol under the cursor in the preview window
<C-w>}
You'll need to index your project with ctags or some compatible program for that feature to work, though.
" doesn't need ctags
:psearch foo
I use ctags, taglist, etc., to have auto completion in Vim. However, it is very limited compared to Visual Studio intellisense or Eclipse auto-completion. I am wondering whether it is possible to tune Vim to:
Show auto-completion whenever . or -> are typed. But only after some text that might be a variable (e.g. avoid showing auto completion after a number).
Show function parameters when ( is typed.
Stop removing the auto completion list when some delete all characters after . or ->: When I enter a variable name, then press . or -> to search for a certain member, I frequently have to delete all the characters I type after the . or ->, but this makes Vim hide the auto completion list. I would like to keep it visible unless I press Esc.
Showing related auto completion: When I type a variable and press ^X ^O, it usually shows me all the tags in the ctags file. I would like to have it showing only the tags related to the variable.
Thanks for the help.
EDIT: Some people are voting for this question, but no body seems to know the answer. So just wanted to mention that you don't have to provide a complete answer; partial answers to any of the mentioned points would be good also.
AutoComplPop is what you need.
For (1) when working with C++ or C clang complete is a really nice option
To make vim trigger a certain behavior when a key is pressed you need to map the key to a function.
For instance to map the key . to call some type of completion when in INSERT mode you would need to do:
:inoremap <expr> <buffer> . MyFunction()
and then the function would need to evaluate the context where it was called and present an appropriate answer to the user.
Edit: This is the basis of how clang complete mentioned by #honk works.
I'm not sure if you can customize the behavior of omnifunc to meet your needs but on my experience, I never went too far. As #Mikhail said, you would need to keep track of things which in practice means interpreting or even running the code to some extent.
I use vim every day, and I'm not aware of any existing script that may do this. This action would require understanding of classes and keeping track of variables. someObject-> means that VIM would know what class the variable someObject is, and then be able to search methods/variables within that class.
Writing scripts for vim is relatively easy, though like you've commented - no one has answered this yet. Up vote from me.
I would love to have that same functionality that you are looking for and just came across a promising plugin:
https://github.com/Shougo/neocomplcache looks like it could be the new autocomplpop, and seems to work quite well during my initial trials... now to configure the omni completion to work with scala~
I've recently discovered YouCompleteMe, it behaves similarly to the Visual Studio autocomplete tool. A demonstration can be seen here:
https://www.youtube.com/watch?v=YuMyHAHF0xs
In any case, I recommend YouCompleteMe (YCM). It provides (fuzzy) matching of identifiers of your current file, as well as path-completion, integration with external completion engines,...
ad 1)
If you like the semantic completion of eclipse, use eclim to integrate vim with eclipse. (alernatively use another semantic engine for YCM)
ad 2)
These 2 play nicely together btw.,: YCM can even provide the function definition (= parameter list) of the recently completed function!
ad 3)
that's what YCM does anyways
ad 4)
not quite sure, what you mean by that one. never used ctags!
P.S.: I strongly recommend using UltiSnips and Tagbar (and if you like UndoTree) additionally, what makes vim a perfect IDE for me.
Recently I've been trying my hand at using vim instead of TextMate and one of the features that I've missed most in VIM is TextMate's jump to method function (CMD + Shift + T for those who don't know). From looking around I havn't seen any particular way to emulate this functionality and was wondering if anyone here has had experience with this sort of functionality in VIM.
Thanks in advance for any answers
Patrick
You're looking for vim's 'tags' functionality ... I answered a similar question about tags here: How to implement own tag jump in VIM with CTRL-]?
This functionality has been implemented in fuzzyfinder using :FufBufferTag. See the ticket
I'd love to hear good suggestions as I use Vim all the time but haven't used TextMate. I do the following things which slightly overlap.
Search for d-e-f-space-<first few letters of function name>. So to go to function foo (in Python or Ruby, and within the same file of course), I type /def fo and I'm there. I also have incremental search enabled in Vim.
Use marks for functions which I visit often. So I'll ma at the function definition and then 'a back to it later. I know it's not function definitions but it is a crutch.
you can create a tags file with ctags http://ctags.sourceforge.net/
basically $ctags -R
Then once you're in vim :set tags=/path/to/tagsfile
this will also be any tag so not just class names, methods, etc. In normal mode ctrl-] on the method/class/ and it will jump to that position.
You can also use the taglist plugin which will display current tags in a side window. ctags
I had pretty much the same problem and I found a quick and dirty solution (paste this in your .vimrc and call by typing :LS)
function! s:ListFunctions()
vimgrep /function/j %
copen
endfunction
command! -bar -narg=0 LS call s:ListFunctions()
If you require more functionality then Exuberant Ctags will do better for you
I'm using CommandT for file searching, then / to search for a particular function. However, the real issue is with CSS. Cmd Shift T in Textmate enable quick jumps to a particular CSS class, and that is a huge time-saver.
CTags doesn't support CSS parsing, unless you re-compile with a patch (found via google), but I'm not even sure if we can do fuzzy searching for CSS classes like in Textmate. I really miss the Cmd Shift T feature.
I've written a TextMate Bundle command (you can easily assign it to Ctrl+] for example) that lookup for the definition of the class or method under the caret and displays it in a tooltip, along with the file name and the line where it was find.
Check it out: Add a shortcut to TextMate to lookup a class or method definition in a tooltip
Hope you'll find it useful!
The feature described in this question has many different names depending on the IDE/Editor:
In Resharper it's called "Goto File member"
In Sublime Text 2 it's called "Goto Symbol"
In PyCharm it's called "Goto Symbol"
The feature is essentially the same though in all of the above implementations (and I assume it's very similar in TextMate as well). The feature brings up an interactive list of methods/functions (and potentially also includes member variables/properties).
The list allows interactive filtering by typing the name of a methods/functions/etc. The list also usually allows the use of arrow keys to select a method/function/etc. Hitting the enter key with a method/function/etc selected navigates to the line in the current file where the selected method/function/etc is defined.
Of all the existing answers in this question the only one that I see which seems to provide a reasonably similar implementation of this feature is to use the command:
:FufBufferTag
in vim's FuzzyFinder plugin.
The answer which suggests using the taglist plugin is not a good solution, because the functionality offered by the taglist plugin is quite different from the feature. The taglist plugin offers similar functionality - the ability to view an outline of methods in the currently file, but it does not offer an interactive way to filter that list in realtime. The taglist plugin does allow you to search the tag buffer, but that's not nearly as convenient as the "Goto symbol" functionality offered in other editors.
I wanted to provide an alternative suggestion here, which is to use the command:
:CtrlPBufTag
in the excellent Ctrlp vim plugin. In my opinion this by far the best implementation of the "Goto Symbol" feature currently available in vim.