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!
Related
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.
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).
How to do a text search into a cygwin window buffer ? Is there a way to make the same kind of text seach as in Windows console buffer (right-click > search) ?
(I use mintty)
In mintty, you can do that using the sequence Alt+F3.
More information in the mintty man page
Searching in the text and scrollback buffer
Alt-F3 opens a search bar with an input field for a search string. Matches are highlighted in the scrollback buffer. Enter/Shift+Enter find the next/previous position of the match and scrolls the scrollback buffer accordingly. The appearance of the search bar and the matching highlight colours can be customized.
Beware this sequence is very close to the infamous windows sequence that closes a window. (which uses F4)
Alternatively, you can enable the Ctrl+Shift+H shortcut by going into the options pane of mintty and enabling Ctrl+Shift+letters shortcuts in the Key section of the options.
You access the options pane by right-clicking the mintty icon of the mintty window (upper left corner)
There's no such function currently. The closest alternative is to 'Select All' (followed by 'Copy' if you've disabled copy-on-select), paste into a text editor, and search there.
You have a few options.
Use cmd | tee file, then search in the resulting file afterwards.
Use screen's copy/scrollback mode.
(Mintty) I'd mucked up an rsync command (wrong direction) so I wanted to track which files had been altered. So I manually selected the Mintty screen output from the bottom with my mouse hold left mouse button and then push to top of the screen and then tediously waited while the screen scrolled forever backwards then when I'd gone back as far as I needed I did a Control-Insert to copy. I then pasted into a text file which I could then search, edit, grep, vim to my hearts content. Don't know if this the only way but it works!
I used emacs editor as buffer. From emacs open shell : C-x shell, then I can do search within buffer as current window.
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.
Tab completion with a popup menu in vim works pretty well with the right configuration.
http://vim.wikia.com/wiki/Make_Vim_completion_popup_menu_work_just_like_in_an_IDE
I have a small collection of code generator and code manipulating programs which I use in vim. The procedure is:
1. initiate visual mode
2. highlight text
3. :'<,'>!hashify
I would like to harness vim popup menu to offer a selection of actions.
The new procedure would be:
1. initiate visual mode
2. highlight text
3. <Tab> -- select transform option from menu
Is there a vimscript interface which could be used for this?
The insert mode completion popup can be used to insert a choice of text fragments. There are two ways to implement it, see :help complete-functions and :help complete(). If your code generator returns single-line (and not too long) text fragments to insert, you could invoke the generator via system(...) and then feed the returned values to the completion function.
On the other hand, if the menu choices do not directly correspond to inserted text, but are tactical choices or actions, most plugins present a selection menu like this, styled like built-in menus (e.g. from :ilist):
:echohl Title
:echo 'Code fragments:'
:echohl None
:echo '1. foo'
:echo '2. bar'
:let choice = nr2str(getchar())
:if choice == 1 ...
Then, insert the text corresponding to the choice via :normal! iText, or setline().
As you appear to need the completion from visual mode, you can first capture the selected text by starting your mapping with y.
This plugin allows to create popups like that for Vim: