live templates with optional arguments

1) How can I create a live template which may have optional arguments?

function(param1, param2, param3) {
     $END$
}

Where param2 and param3 are optional. I'd like to either TAB thru one (or both) of them or DEL if I don't want the parameter. Result would be

function(param1) { ... }

OR

function(param1, param2) { ..}

OR

function(param1, param3) {...}

1 comment
Comment actions Permalink

Hi there,

I do not think it's possible at all.

I mean -- you can leave params empty .. but commas will still be there.

Better declare just a single parameter and type all of them (1 or 2 or 3) when needed -- it's just a placeholder so you can type anything there:

function $NAME$ ($PARAMS$) {
     $END$
}

0

Please sign in to leave a comment.