开发者

In Vim, can you show a tooltip where the cursor is?

开发者 https://www.devze.com 2023-02-09 10:11 出处:网络
Is there a way to display a tooltip (like a popdown menu, but just wi开发者_如何学JAVAth text), where the cursor is, using VimScript?If you mean a tooltip where the mouse cursor is, then you can do th

Is there a way to display a tooltip (like a popdown menu, but just wi开发者_如何学JAVAth 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!

0

精彩评论

暂无评论...
验证码 换一张
取 消