snippets icon indicating copy to clipboard operation
snippets copied to clipboard

Programmable snippets

Open zehcnas34 opened this issue 11 years ago • 13 comments

Just wondering if there is any way to make programmable snippets like in yasnippets for emacs.

Kinda like:

var BrowserWindow = require('browser-window');

In this example, when typing BrowserWindow the text inside the require statement is converted from camel case browser-window

This would be awesome.

Anyway I could help?

zehcnas34 avatar Feb 19 '15 17:02 zehcnas34

The desired behavior is known as transformations in TextMate snippet terminology. We should probably use that as the starting point for this feature request.

thomasjo avatar Feb 19 '15 18:02 thomasjo

Alright, sounds good. I'll starting looking at the spec.

zehcnas34 avatar Feb 19 '15 21:02 zehcnas34

:+1:

tregusti avatar Aug 09 '15 18:08 tregusti

+1

rossmcf avatar Nov 03 '15 16:11 rossmcf

+1

nweldev avatar Jan 08 '16 16:01 nweldev

+1

paukul avatar Jan 28 '16 07:01 paukul

+1

daimon99 avatar Jun 17 '16 07:06 daimon99

Any news on this, or any guidance where to start looking at?

skaldarnar avatar Nov 23 '16 13:11 skaldarnar

+1

dogancana avatar Nov 24 '16 11:11 dogancana

Rather than use regular expression-based TextMate-style transformations, it might be more flexible to allow calling some kind of user-defined function.

This would allow for regular expressions, but also other things.

I've used this kind of feature in the past in another editor to insert the current date/time, or the current file name, as part of my snippet.

johnbhurst avatar Dec 02 '16 21:12 johnbhurst

I wrote up #257 because I’d missed this one way back in the issues list, but I’m linking it here because it’s got some example use cases and some technical discussion.

savetheclocktower avatar Dec 06 '17 17:12 savetheclocktower

+1

gerarts avatar Jul 07 '18 02:07 gerarts

I’m closing this one because the example described can be done now — #260 added support for snippet transformations.

savetheclocktower avatar Sep 23 '18 16:09 savetheclocktower