开发者

TextMate: Indent settings for JavaScript in <script> tags

Our style guide wants JavaScript to be indented by 4 spaces and HTML by 2.

I've got custom settings for .js and .开发者_Go百科html files. However, when I edit JavaScript inside <script> tags in HTML, TextMate indents the JavaScript by 2 spaces instead of 4.

How can I fix this?


It's possible to create indentation rules in TextMate bundles, but from what I've read, I do not believe it's possible to dynamically change the auto-indentation based on the type of indentation tag. The indentation rules documentation can be found in section 24 of the TextMate manual.

What you could do is add a command to the HTML bundle that has a regex that looks for <script> tags and then properly re-indents the lines preceeding the next </script> tag. You could then run this to automatically fix the indentation. See Commands in the TextMate manual.

Hope this helps a bit...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜