Made "smart tab" and "smart detab" keyboard actions

I often create hierarchical lists with starting with either "- " or “- [ ]” — The Tab keyboard actions I found in the Actions directory leave the cursor before the dash, so I then needed to move it to the end of the line — quite annoying…

So I created these two that do the job to indent or unindent the current line or the entire selection. Note: These replace the Tab and Shift-Tab keys on Mac.

There’s still something funky with the “detab” so the cursor doesn’t get placed in the right place, if anyone has a suggestion how to fix that’d be excellent :slight_smile:

Smart Tab: Smart Tab | Drafts Directory
Smart Detab: Smart Detab | Drafts Directory

Assuming you mean end of the line.

it will outdent and move the cursor to the end of the line.

Then I think this line needs to refer to the selection end minus one, with a length of zero. Currently this just looks badly formed.

editor.setSelectedRange(selStart) - 1;

Not tested, but I’m thinking something like this.

editor.setSelectedRange(selStart + selLen -1, 0);

Hope that helps.

Amazing, thanks! Updated and published to the Action Directory