Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create Snippet with variables in Atom

Is it possible to incorporate variables into snippets in Atom? This comes in handy with for loops for example, when you want to pre-fill spots that are about to come.

The snippets.cson entry with java as a source I would imagine. Unfortunately it is not working.

'.source.java':
    'For-Loop':
        'prefix': 'fori'
        'body': 'for (int ${1:VAR} = $2; ${VAR} < $3; ${VAR}++) {\n\t$3\n}'
like image 829
TomTom Avatar asked Oct 15 '14 21:10

TomTom


1 Answers

Current version of Atom can support this kind of snippet. You can just put $1 at every places you want.

'.source.coffee':
  'For-Loop':
    'prefix': 'fori'
    'body': 'for (int ${1:i} = $2; ${1:i} < $3; ${1:i}++) {\n\t$4\n}'
like image 152
Tiger Feng Avatar answered Oct 24 '22 08:10

Tiger Feng