Atom - fragments not working

Below are the two snippets I wrote in the snippets.cson file:

'.source.python':
  'print statement':
    'prefix': 'pr'
    'body' : 'print "${1:Hello world}"'


'.source.python':
  'Argument variables import':
    'prefix' : 'argv'
    'body' : 'from sys import argv'

      

The first doesn't work, but the second does. Help me please.

Ps.

The snippets file was BLANK when I first installed atom on my machine. I am using Ubuntu 16.04. This is normal?

+3


source to share


1 answer


I believe the root of your problem is that your scope has .source.python

been declared twice.

First answer your second question: No, my snippets.cson file was not empty when I first opened it. Instead, it contained the following:

# Your snippets
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values.
#
# You can create a new snippet in this file by typing "snip" and then hitting
# tab.
#
# An example CoffeeScript snippet to expand log to console.log:
#
# '.source.coffee':
#   'Console log':
#     'prefix': 'log'
#     'body': 'console.log $1'
#
# Each scope (e.g. '.source.coffee' above) can only be declared once.
#
# This file uses CoffeeScript Object Notation (CSON).
# If you are unfamiliar with CSON, you can read more about it in the
# Atom Flight Manual:
# http://flight-manual.atom.io/using-atom/sections/basic-customization/#_cson

      

(However, this is on macOS).



Note how he instructs you that each area can only be declared once. I think that if you change your two fragments to be included in the same scope, they work as expected.

Changing yours snippets.cson

to the following looks to me:

'.source.python':
  'print statement':
    'prefix': 'pr'
    'body' : 'print "${1:Hello world}"'

  'Argument variables import':
    'prefix' : 'argv'
    'body' : 'from sys import argv'

      

I can access both fragments from the fragment import menu when I make the region .source.python

unique.

+4


source







All Articles