Atom.io编辑器中用户代码段的全局范围

时间:2014-04-10 20:32:51

标签: sublimetext atom-editor code-snippets language-comparisons

我想将我为Sublime Text 3编辑器编写的一些片段转换为atom.io编辑器。

由于我的“license”代码段对任何类型的文件(任何文件扩展名)都有效,因此我在licence.sublime-snippet文件中指定了范围:

<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->

现在,我在atom/snippets中看到了上面的例子。

'.source.js':
  'console.log':
    'prefix': 'log'
    'body': 'console.log(${1:"crash"});$2'
  

最外面的键是这个片段所在的选择器   活性

但我无法弄清楚如何指定全局范围或更好根本不指定以及我在{{1}中所做的}。任何帮助表示赞赏;特别是还没有找到详细的操作片段原子的综合文档,因此也欢迎这种文档的一些链接。

2 个答案:

答案 0 :(得分:23)

这是你正在寻找的吗?

'*':
  'console.log':
    'prefix': 'log'
    'body': 'console.log(${1:"crash"});$2'

答案 1 :(得分:2)

@Basil Musa:为了在(js和html)文件中提供一个片段,你可以像这样指定:

 '.html.js':
  'snippet-name':
    'snippet-shortcut': 'log'
    'snippet-body': 'console.log(${1:"placeholder"});$2'
相关问题