show function parameters in vim

女生的网名这么多〃 提交于 2019-12-03 09:00:44

问题


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.

  1. I'm looking for something a bit more comfortable than ctrl-w ctrl-]

  2. I'm also looking for a similar functionality that will show me list of available members when typing "var->" or "var."

  3. I'm using C


回答1:


Do check out the autocomplpop and TTrCodeAssistor plug-ins.




回答2:


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.




回答3:


YouCompleteMe is a nice alternative that offers fuzzy autocompletion and uses clang to deal with the semantics.




回答4:


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.



回答5:


Or you can try vim-assistant script.



来源:https://stackoverflow.com/questions/741542/show-function-parameters-in-vim

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!