Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

coffeescript unexpected INDENT

Sometimes when I edit coffeescript files in Sublime text2 I got errors when compile it to js:

error: unexpected INDENT
                        $.post url,

In sublime text2 editor I see valid indents:

Code print screent

But if I copy paste this code in plain editor I see wrong indents:

click: ->
                            debugger;
                        # delete org here
                        $.post url,

debugger; string has wrong extra indent.

So how to edit coffeescript files in sublime text 2 with pleasure? I got installed coffeescript package in sublime.

My Preferences.sublime-settings file is the following:

{
    "auto_indent": true,
    "auto_match_enabled": true,
    "detect_indentation": true,
    "draw_centered": false,
    "font_size": 11.0,
    "ignored_packages":
    [
        "Better CoffeeScript",
        "Vintage"
    ],
    "indent_guide_options":
    [
        "draw_active"
    ],
    "indent_subsequent_lines": true,
    "indent_to_bracket": true,
    "smart_indent": true,
    "tab_size": 2,
    "translate_tabs_to_spaces": true,
    "trim_automatic_white_space": true,
    "use_tab_stops": true,
    "word_wrap": "auto",
    "wrap_width": 0
}
like image 377
Maxim Yefremov Avatar asked Dec 11 '22 13:12

Maxim Yefremov


1 Answers

It looks like you are mixing tabs and spaces. Select View->Indentation and make sure that Indent Using Spaces is checked, then click Convert Indentation to Spaces and you should be all set.

like image 51
MattDMo Avatar answered Feb 24 '23 03:02

MattDMo