Atom-片段不起作用 [英] Atom -- snippets not working

查看:64
本文介绍了Atom-片段不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我在snippets.cson文件中编写的两个摘录:

The following are two of the snippets I have scripted in 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 one doesn't work, but the second one does. Help please.

Ps.

当我第一次在机器上安装atom时,片段文件为空白.我使用Ubuntu 16.04.正常吗?

The snippets file was BLANK when I first installed atom on my machine. I use Ubuntu 16.04. Is that normal?

推荐答案

我相信问题的根源是您的范围 .source.python 被声明了两次.

I believe the root of your problem is that your scope .source.python was declared twice.

首先要回答您的第二个问题,不,我第一次打开时,我的snippets.cson文件不是空白的.相反,它包含以下内容:

To answer your second question first, No, my snippets.cson file was not blank 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

(尽管这是在MacOS上).

(This is on MacOS, though).

注意它如何指示您每个作用域只能声明一次.我认为,如果您将两个代码段修改为包含在同一范围内,它们将按预期工作.

Notice how it instructs you that each scope can only be declared once. I think if you modify your two snippets to be included in the same scope, they will work as expected.

将您的 snippets.cson 更改为以下内容似乎对我有用:

Changing your snippets.cson to the following appears to work for me:

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

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

一旦使 .source.python 范围唯一,就可以从代码片段导入菜单访问这两个代码片段.

I can access both snippets from the snippets import menu once I make the .source.python scope unique.

这篇关于Atom-片段不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆