     save: =>
         text = @$pad.val()
         # replace tabs by spaces
-        space = (" " for _ in [0...@tabwidth]).join("")
+        space = (" " for _ in [0...@tab_width]).join("")
         text = text.replace(/\t/g, space)
         # strip trailing white space onlines
         text = text.replace(/[ \r]*\n/g,"\n").replace(/\s*$/g, "\n")

        @set_text(text)

        if just_tab
            @$pad[0].selectionStart = real + 4
            @$pad[0].selectionEnd = @$pad[0].selectionStart
        else
            @$pad[0].selectionStart = @lines[start][1]
            @$pad[0].selectionEnd = @lines[end][2] + 4 * (end-start+1)

    deindent: =>
        [start, end] = @selected_line_range()
        lines = (l[3] for l in @lines)
        for n in [start..end]
            for t in [0...4]
                if lines[n][0] == " "
                    lines[n] = lines[n][1..]
        text = (l for l in lines).join("\n")
        @set_text(text)
        @$pad[0].selectionStart = @lines[start][1]
        full_length = 0
        for n in [start..end]
            full_length += lines[n].length
        @$pad[0].selectionEnd = @$pad[0].selectionStart + full_length

    set_text: (text) ->
        @$pad.val(text)

        return false

    insert_text: (add) =>
        [text, [start, end], s] = @get_text_state()
        text = text[..start-1] + add + text[end..]
        start += add.length
        end += add.length
        print [text, [start, end], s]
