abo-abo / auto-yasnippet

quickly create disposable yasnippets
246 stars 15 forks source link

Midword expansions #12

Closed Kethku closed 9 years ago

Kethku commented 9 years ago

Need some way to make a expansion point (I don't know what the actual term is) in the middle of a method name. For instance, as it is now if there is a camel case identifier with a ~ in the middle it will take the remainder of the camel cased word as the identifier which is probably not what we want. As an example:

public void ~1TestMethod() ...

Ideally this would let me use the auto snippet and have the generated name just end with TestMethod, however instead it removes the whole method name. Doubly bad is the fact that I can't mirror this identifier because it thinks the whole identifier is 1TestMethod.

It is possible that I am missing something silly, so if somebody could enlighten me or confirm the issue, that would be great :)

abo-abo commented 9 years ago

You're looking for:

public void `First'TestMethod ()

Afterwards, this is easy:

public void SecondTestMethod ()
Kethku commented 9 years ago

You rock. Exactly what I wanted, thanks! Would you like me to add something to the readme to make this more discoverable?

Kethku commented 9 years ago

Possibly another example with the others near the bottom?

Kethku commented 9 years ago

Ok wait one more question. Can you have multiple quoted sections to complete in the same snippet?

I can't seem to get this to work:

public void `1'TestMethod(~2 param)

or

public void `1'TestMethod(`2' param)
abo-abo commented 9 years ago

I rewrote some code to support multiple and mixed quoting. Please test.

Kethku commented 9 years ago

I tested it and it works well. The only thing I would say is that the ability to have a mixture of the quote style and $ substitutions would be nice. I could be wrong but it seems like its one or the other at the moment.