Here is the deal,
If you've used Aptana, Eclipse or even Microsoft Expression Web editor, then you've seen that they feature a Balloon Text or Intellisense popup showing hints/info of built-in and custom objects, methods, etc.
They get the info thru JSDoc, PHPDoc, JavaDoc, RDoc, etc.
I'd like to get these feature in Vim, maybe implemented as omnicompletion and also since Mac/GVim supports balloon text, as this as well.
This feature actually exists and is defined in each file type's Omni-completion. For example, enabling PHP's omni-completion will show completions in a popup window as well as the method definition in a smaller buffer which opens at the top of the current tab-frame.
Activate it by adding the following to your .vimrc
filetype plugin on
au FileType php set omnifunc=phpcomplete#CompletePHP
And then using C-x C-o for completion. (I find many people like to remap this to C-space to mimic Visual Studio)
More information and links about omnicompletion can be found at http://vim.wikia.com/wiki/Omni_completion
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).
Is there any way in gvim to obtain a clickable code folding margin, similar to the one available in diff mode? Please refer the diff mode screenshots attached.
Note that I am comfortable using the keyboard commands for code folding, but sometimes clicking is more convenient.
I have searched on the internet and also here. I have only found material which explains the keyboard commands, but nothing about the clickable option.
Edit I use gvim version 7.0.
Assuming that folding has been set up for your filetype (i.e. you can use keyboard commands like za), you just need to enable the fold column with a specified width, e.g.:
:set foldcolumn=4
If you set this globally, it will always be there. If you only want to enable it for certain filetypes (that actually have folding), and/or adapt the width to the amount of nested folding, use :setlocal foldcolumn=... instead, and put the corresponding commands into ~/.vim/after/ftplugin/<filetype>.vim, where <filetype> is the actual filetype (e.g. java). (This requires that you have :filetype plugin on.)
Alternatively, you could define an :autocmd FileType <filetype> setlocal foldcolumn=... directly in your ~/.vimrc, but this tends to become unwieldy once you have many customizations.
Like Visual Studio when you type-in a tooltip shows you the summary (documentation) of lib/objects/functions etc.
Suppose, I'm experimenting with DataMapper. I would like to see what it has and what each of them can do (purpose) without leaving vim. Is this possible?
Although I'm doing PHP development, not Ruby, I think this will also work for Ruby:
For PHP (Drupal) I generate a tags file with ctags and configure vim to use this tagfile by setting the tags-option. (see :help tags).
Now when I start typing a function-name I can press CTRL-X CTRL-O to start Omnicompletion. Vim show a list of all possible completions and you can select next/previous suggestions with CTRL-N and CTRL-P. When selecting a completion Vim also shows the function declaration in a preview window.
You can close the preview window with the :pclose-command.
The preview will only show up if the completeopt-settings contains the preview value (see :help 'completeopt')
I'm currently trying to switch from Coda (a Mac IDE) to Vim. One thing I loved about Coda and my knowledge of Vim cannot replace were the so-called "clips". Basically, you type, say, "new", press TAB, and the text is replaced with a basic XHTML page. And you can add as many keyword/clips combinations as you want.
The most I could get with Vim so far was to create a new file containing my clip, and then use :r FILE in Vim in order to get it inserted, but this is not a very elegant solution, as I'd have to carry these clips around in every directory I have a file I want to use my clips with.
So assuming I've explained things properly, what would be my choices?
For various editors, there's a functionality called '''snippets''' which tab expands the beginnings of common text (like a HTML div, or C function definition) into a skeleton for that code.
There's a couple vim plugins that present this functionality. Two off the top of my bookmark list:
snippetsEmu
snipMate
I heard of another plugin for quick HTML editing that uses snippets recently:
zencoding
Check those out and see if they're near what you're looking for.
Also, you can define a default BufNewFile action in vim - which lets you read in a skeleton for a file if it doesn't already exist automatically.
*skeleton* *template*
To read a skeleton (template) file when opening a new file: >
:autocmd BufNewFile *.c 0r ~/vim/skeleton.c
:autocmd BufNewFile *.h 0r ~/vim/skeleton.h
:autocmd BufNewFile *.java 0r ~/vim/skeleton.java
Put those (or the equivalent) in your .vimrc (w/o the leading colon) to have them set up automatically every time you run vim.
Very late to the party, but:
I would recommend something like Dash for this, because the snippets are then available across all your apps.
This can be a significant bonus as your muscle-memory starts to rely on particular snippets, and can also ease the transition from one editor to the other, because your snippets are independent.
Sometimes I find myself using snippets in something like Mail to send to someone else, or in a Vim terminal on a remote machine I haven't configured, and it's great to have them all there at the ready.
Now all we need is a cross-platform solution which moves with you to a colleague's machine!
As well as the various snippet plugins, Vim also has an abbreviation feature built in, using the :ab[breviate] command.
For example you can define this:
:ab <h <head>^M</head>^M<body>^M<\body>
Then when you type <h<SPACE> it will expand into the full text. The ^M in the example above are actually carriage returns inserted in the string definition with <ctrl-V><RETURN>.