2017-06-26 1 views
3

を働いていないスニペットは、私がsnippets.csonファイルにスクリプト化しているスニペットの2つです:アトム次

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


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

最初のものは動作しませんが、もう一つはありません。助けてください。

ps。

私のマシンにアトムを最初にインストールしたとき、スニペットファイルはBLANKでした。私はUbuntu 16.04を使用しています。それは普通ですか?

答えて

4

あなたの問題の根本は、あなたのスコープ.source.pythonが2回宣言されたと信じています。

最初に2番目の質問に答えるには、いいえ、私のsnippets.csonファイルは最初に開いたときに空白ではありませんでした。代わりに、次の内容が含まれていました:

# 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 

(これはMacOSにあります)。

各スコープは一度しか宣言できないことに注意してください。 2つのスニペットを同じスコープに含めるように変更すると、期待どおりに動作します。以下に、あなたのsnippets.csonを変更

は私のために動作するように表示されます。

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

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

私は.source.pythonスコープを一意に一度スニペットから、両方のスニペットは、メニューをインポートアクセスすることができます。

+1

私は以前にWindows 10にアトムをインストールしており、このようなものを読んだことを覚えています。しかし、Ubuntuでは文字通り空白です。\ –

+0

どの宣言が優先されますか?前か後? –

+1

私はそれが宣言的な言語であると思われるので、_after_と思われます。また、OPは、彼の2番目のスニペットが機能していたが、最初のスニペットは動作していないと示唆した。 – jwir3

関連する問題