Question

Here's my snippet:

# Get repository of a table:
snippet repo
    $$2 = $this->getRepository('${1:Bundle}:${2:TableName}')
    ${3}

When I use it, here's what it may generate:

$Person = $this->getRepository('MyBundle:Person')
$Address = $this->getRepository('MyBundle:Address')

I would like the first one to be lowercase, always lowercase, and give me something like:

$person = $this->getRepository('MyBundle:Person')
$address = $this->getRepository('MyBundle:Address')
...

. Is there a way to do this with the snipmate?

Was it helpful?

Solution

This cannot be done with snipMate. I've tried to implement this, but (especially when the transformation changes the number of characters), it's impossibly hard with the current implementation.

That may be the best reason to move to the UltiSnips plugin, a modern, maintained alternative (that however requires Python support). There, the feature is called transformation, and uses a ${<tab stop no/regular expression/replacement/options} syntax. You can use the \L regular expression atom to lowercase the replacement.

OTHER TIPS

I don't think it's possible with snipmate but you may have a look at UltiSnips. UltiSnips uses a very similar template syntax (very easy to convert) and is much more versatile. http://www.vim.org/scripts/script.php?script_id=2715

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top