snippetのREADMEの翻訳っぽいもの.
Snippet package
tab
を入力すると,直前に入力しているプリフィックスにマッチするスニペットが展開されます.
Atom > Open Your Snippets メニューを選択するとスニペットの追加が行えます.
Snippet Format
スニペットはパッケージの snippets/
フォルダに保存されています.
また.atom/snippets.cson
からも読み込まれます.
スニペットファイルは.json
, .cson
のどちらかで作成できます.
'.source.js':
'console.log':
'prefix': 'log'
'body': 'console.log(${1:"crash"});$2'
トップレベルのキー(.source.js
)はスニペットが適用されるセレクタです.
次のインデントのキー(.console.log
)はスニペットの名前です.
各スニペットには
-
prefix
スニペットを展開するときに指定するプリフィックス -
body
スニペット本文を指定します.
あとで訳す
$ followed by a number are the tabs stops which can be cycled between by pressing tab once a snippet has been triggered.
The above example adds a log snippet to JavaScript files that would expand to.
console.log("crash");
The string "crash" would be initially selected and pressing tab again would place the cursor after the ;
複数行のbody
"""
で囲みます.
'.source.js':
'if, else if, else':
'prefix': 'ieie'
'body': """
if (${1:true}) {
$2
} else if (${3:false}) {
$4
} else {
$5
}
"""
(以下は翻訳ではありません.)
変数も使えます.
HEADER =
'prefix': 'header'
'body' : """
## @author kazup0n(@kazup0n)
## all rights reserved.
"""
'.source.coffee':
'header': HEADER
'source.rb':
'header': HEADER