Pradino
Pradino

Reputation: 462

Custom PHP snippet in Atom

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.

Upvotes: 3

Views: 2988

Answers (1)

anon
anon

Reputation:

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

Upvotes: 8

Related Questions