Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Missing: Proper Indentation and Code Folding #4

mxmerz opened this Issue · 3 comments

2 participants


Hi, I use the Erlang bundle a lot and I'd like to point out two things that really bug me: Indentation and Code Folding.

For example, I start typing this (caret indicates the caret):

function() ->

and then hit return, I stay on the same indentation level:

function() ->

Even worse, if I delete the tab, hit return and start with my next function, I get back-indented.
I've got the same problem with the semicolon:

function () ->
    case expression of
        pattern when guard ->

I hit return:

function () ->
    case expression of
        pattern when guard ->

I tried to fix this myself by modifying decreaseIndentPattern but I'm not that good with regular expressions (and therefore failed). As far as I know, code folding doesn't exist at all in the Erlang bundle.

Is it even possible to solve this indentation-/code-folding-problem with Textmate bundles, regarding the "unusual" syntax of Erlang?


Okay, I digged a bit deeper and now I'm frustrated. The problem seems to be how TextMate handles indentation and code folding:
TextMate seems to be incapable of assigning more than one indentation- or folding-attribute to a single line. Also, the "closing" line has to be at the same indentation level as the "opening" line to let folding work.
Both of these limitations make it impossible to do proper Erlang code indentation/folding:

%% How you would normally write Erlang:
function1(Tralala) -> %% opening statement (1)
    case morgen_kommt_der() of %% opening statement (2)
        nikolaus -> %% opening statement (3)
            butzemann; %% closing statement (3), one indentation level 
                       %% above it's opening statement
        {ok, haenschen} -> %% opening statement (4)
            [klein, Tralala] %% implicit closing statement (4)
    end. %% closing statements (2) and (1) in one line
%% What I got working in TextMate:
function2(Tralala) ->
    case morgen_kommt_der() of
        nikolaus ->
        {ok, haenschen} ->
            [klein, Tralala]
        ; %% compile error 

The latter would be rather ugly and wrong Erlang code.
I hope I'm missing some undocumented feature of TextMate 2.0 that makes Erlang indentation and code folding possible, but I'm not too optimistic.


Fully correct indentation isn't currently possible with TextMate. I have disabled the re-indentation it will do in abafcb9 and added folding for functions in 9c884e3.


Wow, thank you!

@mxmerz mxmerz closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.