Atom 编辑器:多个片段 [英] Atom Editor: multiple snippets

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

问题描述

这是一个如此简单的问题,但除了自述文件之外我找不到任何文档.

This is such a simple question but I can't find any documentation besides the readme.

如何在 Atom 编辑器中拥有多个自定义片段:

How can I have multiple custom snippets in Atom Editior:

例如我现在在我的snippets.cson中有这个

For example I have this in my snippets.cson right now

'.source.js':
  'Normal Comment Block':
    'prefix': 'cmm'
    'body': """
      //**********************************************************************************
      //
      //**********************************************************************************
    """

'.source.js':
  'Dashed Comment Block':
    'prefix': 'c--'
    'body': """
      //----------------------------------------------------------------------------------
      //
      //----------------------------------------------------------------------------------
    """

但是cmm不起作用,我只能使用snippets.cson中的最后一项.有想法该怎么解决这个吗?我想使用大约十几个不同的片段,但我不知道如何正确包含它们.

But cmm doesn't work, I can only use the last item in the snippets.cson. Any ideas on how to fix this? I have about a dozen different snippets I'd like to use but I cannot figure out how to include them properly.

推荐答案

配置文件格式称为 CSON,CoffeeScript Object Notation.与 JSON(JavaScript Object Notation)一样,它是一种用于描述简单对象的文本格式.因此,当您指定一个键两次时,例如您的示例中的 .source.js,第二个实例会覆盖第一个实例.如果你只有一个 .source.js 一切都会正常的:

The configuration file format is called CSON, CoffeeScript Object Notation. Like JSON (JavaScript Object Notation) it is a text format for describing simple objects. Because of which, when you specify a key twice, like .source.js in your example, the second instance overwrites the first. If you simply have one .source.js everything will work fine:

'.source.js':
  'Normal Comment Block':
    'prefix': 'cmm'
    'body': """
      //**********************************************************************************
      // $1
      //**********************************************************************************
      $0
    """
  'Dashed Comment Block':
    'prefix': 'c--'
    'body': """
      //----------------------------------------------------------------------------------
      // $1
      //----------------------------------------------------------------------------------
      $0
    """

此外,我冒昧地为您的代码段添加了制表位,这样当您展开代码段时,您的光标应该首先落在评论中.您可以输入您的评论,然后按 TAB 退出并继续.

Additionally, I took the liberty of adding tab stops to your snippets so that when you expand the snippet, your cursor should land first inside the comment. You can enter your comment and then press TAB to exit out and continue on.

这篇关于Atom 编辑器:多个片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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