8

I am trying to override default snippets in Atom, because I want to change the default script snippet from

<script charset="utf-8"></script>

to

<script src=""></script>

I have put the following into snippets.cson.

'.text.html':
  'Comment':
    'prefix': 'com'
    'body': '<!-- $1-->'
  'Script':
    'prefix': 'script'
    'body': '<script src="$1"></script>'

My 'com' snippet works fine. But script results in the default snippet, not my new one.

2 Answers 2

3
  1. Add a snippet that overwrites an existing snippet
  2. Quit Atom
  3. Start Atom
  4. Trigger the newly added snippet, and the original snippet will trigger
  5. Open the ~/.atom/snippets.cson file and Save the file (no changes need be made)
  6. Trigger the snippet again and it will use the customized version

Apparently its a bug right now.

via https://github.com/atom/atom/issues/2695

Sign up to request clarification or add additional context in comments.

3 Comments

Just quitting and starting again worked for me on Atom 1.2.4
Hey, sorry but I don't use Atom anymore so I have no idea if this works on newer versions. It seems like since this was a bug they would have fixed it eventually though.
is there a file which holds all the atom core snippets so i can see how it's done by default?
0

As of 1.19.5 I can override atoms default snippets by using the traditional procedure for creating snippets, which is written in coffeescript. For example, overwriting my require method looks something like . . .

    '.source.[*yourlanguage*]':

    'Require':
    'prefix': 'r'
    'body': "require '$1' "

More descriptively

  • Navigate to "snippets" via the file dropdown menu.

  • Follow the instructions listed, or continue with me.

  • Copy and paste the code I've provided above, below. Replace the yourlanguage with the language you are writing the code for you.

  • Open a new file, type the character following the 'prefix':, press tab.

  • This should give you enough information to contextually figure out how to both overwrite, and write original snippets.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.