3

I have been trying to add PHP snippet in Atom in MAC but the snippet does not work in the editor itself. A sample snippet I am trying to use is as below:

'.text.html.php': 'Paragraph tag': 'prefix': 'ptag' 'body': '<p>{1}</p>'

The scope is

text.html.php

When I try to access the snippet by typing "ptag" and hit tab nothing happens. Looks like I am missing something, help.

1 Answer 1

8

While .text.html.php scope is correct you might want to extend it to HTML files. In order to do that .text.html and .text.html.php should be separated with a comma:

'.text.html, .text.html.php':
  'Paragraph tag':
    'prefix': 'ptag'
    'body': '<p>${1}</p>'

Alternatively you could set the scope to .text.html,php.

To position the cursor inside p tag you have to write ${1} instead of {1}. If you want to add additional text to it you can use ${1:paragraph}, so that it will generate <p>paragraph</p> and paragraph will be selected for modification.

You can read more about snippets in Flight Manual

Edit: Fixed scope as noted by Adam

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

4 Comments

Thanks! both scope notified simply works '.text.html, .text.php' or '.text.html,php'
@Adam It works indeed. Thanks for pointing this out. I've edited the answer accordingly.
Where to add above?
@M.sulemanKhan To snippets.cson file which you can access by selecting File > Snippets/Edit > Snippets/Atom > Snippets menu (depending on your OS). You can find more detailed information here: flight-manual.atom.io/using-atom/sections/snippets/…

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.