2

I want to create custom snippets in Atom, but I want to be able to supply custom variables and it automatically uses those. For example, I want to be able to type something like nm methodName param1 param2 and it generates the code:

methodName(param1, param2) {

}

However, when reading over the documentation, I see it explain how to create a premade code snippet, but I don't see it explain how to do a snippet that would change based on what was submitted. Do any of you have any idea how to do this?

2
  • Does this answer cover what you want to know?
    – ldtcoop
    Commented Jul 22, 2019 at 22:14
  • @idtcoop Kind of, but not really. I want to be able to submit as many variables as I want, and not have a specified number beforehand Commented Jul 23, 2019 at 17:06

1 Answer 1

0

It doesn't seem like there is a way to do what you want to do -- see the accepted answer for this question. You may be able to find or build an extension that lets you do that, but it doesn't seem to exist in Atom by default.

What you can do is set up custom snippets that are relatively open to a lot of different uses. For example, to make a new method, you could try this, which will let you name the function and type in as many arguments as you want:

    'New Method':
      'prefix': 'nm'
      'body': """
        ${1:methodName} (${2:argList}) {
            ${3:functionBody}
        }
      """

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.