Sunday, September 8, 2013

Re: Trailing space with UltiSnips snippet

On 09/08/2013 07:33 AM, Marco wrote:
> I use the UltiSnipsāļ™ plugin and have a snippet as follows:
>
> snippet sst
> \start${1} ${2}
> ${3}
> \stop${1/\s*//g}
> $0
> endsnippet
[...]
> But this snippet should also work without an argument, but it leaves
> a trailing space:

I think the "s" flag may be what you're looking for. From the
UltiSnips help:

s Remove whitespace immediately before the cursor at the end of a line
before jumping to the next tabstop. This is useful if there is a
tabstop with optional text at the end of a line.

Using that flag, your definition becomes:

snippet sst "some description" s
\start${1} ${2}
${3}
\stop${1/\s*//g}
$0
endsnippet

See the following section in the help for more information:

:help UltiSnips-syntax

Michael Henry

--
--
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:

Post a Comment