Sublime Text 2 + Emmet で閉じタグの後ろにコメントを加える設定
Emmetのカスタマイズ シリーズ1 1で終わるかも。。(笑)
前回、「Sublime Text2用ZenCodingで閉じタグの後ろにコメントを加える方法」という記事を書きましたが、ZenCodingの新しいバージョン、Emmetを使っている人も多いと思います。
そこで、今回は、Emmetでも、閉じタグの後ろにコメントを自動的に挿入する方法です。
C:\Users\<ユーザ名>\AppData\Roaming\Sublime Text 2\Packages\Emmet\emmet
の emmet-app.js をいじります。
12477行目に移動します。
} else { start = '<' + tagName + attrs + '>'; end = '</' + tagName + '>'; }
この部分を
} else { start = '<' + tagName + attrs + '>'; // end = '</' + tagName + '>'; if (attrs.indexOf("id=")!=-1 || attrs.indexOf("class=")!=-1) { var commentStr = '/' + attrs.slice(1); commentStr = commentStr.replace('id=', '#'); commentStr = commentStr.replace('class=', '.'); commentStr = commentStr.replace(/"/g, ''); end = '</' + tagName + '><!-- ' + commentStr + ' -->'; } else { end = '</' + tagName + '>'; } }
と書き換えます。