In vim, when using an autocomplete plugin (or just vim's built-in omnifunc), a window will pop up next to the cursor with completion suggestions:
Vim tries to be smart about where to put this menu, putting it below the cursor most of the time, but above the cursor if you're near the bottom of the window and don't have space to see the window.
I recently updated to a new version of vim (and YouCompleteMe, the autocomplete plugin that I use), and it seems that vim (or YCM, not sure which is responsible) is now overly aggressive in putting things above the cursor instead of below, where basically if you're in the top half of the window, the popup menu is below the cursor, while if you're in the bottom half, the popup menu is always above the cursor.
My question is, how do I control this behavior? It seems like it's probably a vim setting, but in all of my searching I couldn't find anything that would hint at how vim decides whether to put the popup menu above or below the cursor.
The only completion-related options are 'complete' and 'completeopt'. The placement of the complete popup menu is hard-coded in Vim's source code.
If you think this has changed for the worse in a recent Vim version, please open an issue at the bug tracker, or directly discuss this on the vim_dev mailing list.
Related
I have been googling for a way to use vim bindings inside normal text fields in chrome. I've tried vmium and cVim but I can't figure out whether they have the functionality I'm looking for.
An example is this exact text area in which I'm typing my question. I'd like to be able to press Esc and go to vim command mode in here, and start deleting a line pressing dd.
Would that be possible? Or those plugins are just for navigation shortcuts?
Here's the answer!
Those plugins are for navigation only. If you want a Vi-like
experience in Chrome's textareas, try Wasavi. – #romainl
The cVim plugin allows for keyboard shortcuts to manipulate text inside text boxes. However, the shortcuts are not the same as vim and there are not as many. After installing the extension type ":help" to see the list of shortcuts.
I was wondering if there is a way to show code errors in balloons like Syntastic when mouse hover on it.
Yes, there is a way, the one Syntastic is using already: "Balloon Evaluation" (read :h balloon-eval). You can basically set a balloonexpr which defines the text to show in the balloon. If you want to show the balloons by only hovering the mouse regardless of where the cursor is, that is not supported by VIM at the moment. To be honest, that sounds like a very useful idea for a popup menu on right-click (see :h mousemodel).
While coding Python, I like Vim's omnicompletion function, but I don't want Scratch Window to pop up at top.
How can I disable it?
(I'm using gVim 7.3)
This behavior is defined by the presence of preview in the value of the 'completeopt' option.
The default value is:
menu,preview
To remove preview, simply add this line to your ~/.vimrc or modify an existing completeopt line:
set completeopt-=preview
If you don't mind the preview window too much, but want to easily close it, you can use the :pclose command or CTRL-W z keyboard combination see :help :pclose.
I'm currently using superTab for completions in Vim. However, I'd like the completions to be more like bash. For example, if I'm typing
st
and the possible completions are
struct, string
I'd like it to be completed to
str
if I press tab, and ideally display a menu of possible completions.
Plugins are OK.
EDIT: completeopt+=menu, longest does most of what I want, but after the menu pops up and I narrow it down some, pressing tab again does a full completion instead of giving the next longest common prefix.
:set completeopt+=longest
should do the trick.
A great resource for tweaking the completion is Make Vim completion popup menu work just like in an IDE.
Is there a way to display a tooltip (like a popdown menu, but just with text), where the cursor is, using VimScript?
If you mean a tooltip where the mouse cursor is, then you can do this by turning the ballooneval option on and setting the bexpr option to point to a function that returns your required tooltip. This is only available if you're using a vim compiled with +balloon_eval (see :version). Have a look at my (rather basic) tag balloons script for an example.
If you mean a tooltip where the normal vim cursor is, I don't think there's a very clean way to do this. You could create a custom menu with the text that you want (using amenu) and map the command to :nop<CR> and use :popup to display it:
amenu ]MyMenuName.The\ Text\ You\ Want :nop<CR>
popup ]MyMenuName
However, this will only work in the Win32 and GTK GUIs.
I don't know of a way to use the insert mode popup menu (the one used for Ctrl-P and omnicompletion etc) to just display some text. You could abuse the completion method to give your own text as the completion alternative and set menuone in completeopt to allow a single line to be shown, but it would probably overwrite the current text with the contents of the popup menu. It would probably also break omnicompletion!