Thursday, August 25, 2016

Re: Create Autocompletion snippets for Custom Code

Hi,

> I am looking into that. I am beginner/intermediate level of Vim user.
> And I find it really hard to add my own custom snippet in the
> mu-template. Can you give me some ideas of how to add simple
> snippets.
>
> For example
> -----------
>
> I would like to add the following for the trigger `openr`.
>
> OPENR, unit, filename, /GET_LUN
>
> cursor here
>
> CLOSE, unit
> FREE_LUN, unit

Indeed, I see I shall add a "how do i create a new snippet/template?" section in the help.

I don't know the filetype your snippet is for, let's say it's "foobar".

Create a "template/foobar" directory under the vimfiles/ directory in your $HOME (%HOMEDRIVE%%HOMEPATH% in windows).

In your $HOME/vimfiles/template/foobar, create a file named openr.template, it should get filed with default mu-template boilerplate settings.

Then, add what you want in your template file. If you keep the default

VimL: let s:marker_open = '<+'
VimL: let s:marker_close = '+>'

Your can define placeholders with "<++>", or "<+placeholdername+>". It's even possible to accept parameters that can be injected from other snippets, or programmatically. (see :h s:Params()).

So, I guess, your template would look like:

VimL: let s:marker_open = '<+'
VimL: let s:marker_close = '+>'
OPENR, <+unit+>, <+filename+>, /GET_LUN

<+cursor here+>

CLOSE, <+unit+>
FREE_LUN, <+unit+>



NB: I've simplified the explanation regarding the exact directory where you could put your new template files. see :h MuT-paths-override

HTH,

--
Luc Hermitte

--
--
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/d/optout.

No comments: