add-highlighter global/indent show-whitespaces -tab "│" -indent "│" -spc " " -lf " "

define-command softtab-enable %{
    hook buffer InsertChar \t %{ try %{
        execute-keys -draft "h<a-h><a-k>\A\h+\z<ret><a-;>;%opt{indentwidth}@"
    }}

    hook buffer InsertDelete ' ' %{ try %{
        execute-keys -draft 'h<a-h><a-k>\A\h+\z<ret>i<space><esc><lt>'
    }}
}

define-command toggle-whitespace %{
    try %{
        add-highlighter global/whitespaces show-whitespaces
        remove-highlighter global/indent
    } catch %{
        remove-highlighter global/whitespaces
        add-highlighter global/indent show-whitespaces -tab "│" -indent "│" -spc " " -lf " "
    }
}

