Monday, October 21, 2013

Re: Vimscript - how to make menu/selection similar to `z=` and `g`

On Monday, October 21, 2013 3:23:27 PM UTC+2, Bruno Sutic wrote:
> I began learning vim script from the most excellent resource: http://learnvimscriptthehardway.stevelosh.com/
>
> I noticed 2 things "vim can do", but I don't know how to re-use for my scripts:
>
> 1. when the cursor is on a spelling error, you can press `z=` to get a list of possible corrections. Is there a way I can get that behavior and use it for other things?
> Naturally, I wouldn't use that for spell correction - but for let's say a choosing an option from a long list.

You can, and many plugins already do. Though it works in insert mode
(like CTRL-X CTRL-S). The documentation has a full example. It's at:

:h complete-functions

> 2. when using ctags with vim, you can press g<Ctrl-]> to get a (colored) "menu" with a list of matching tags and a prompt to jump to selected tag (just a note - the menu and prompt is shown only if there's more matches for the current tag).
> Now, the same as above - is there a way to get this exact menu/prompt for other scripts and other uses?

You can use inputlist(), but probably not with colours.

:h inputlist()

Check out ":h function-list", too, maybe there's something more to your
liking.

Best,

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: