Action
Smart Detab
UPDATES
over 1 year ago
Fixed bug that would replace selected line(s) with “undefined” if selected lines were not indented.
Removes a tab the beginning of each of the selected lines.
If it is a list (starts with a tab followed by a “-“, “*”, or “+” followed by a space), it will outdent and move the cursor to the end of the line.
Steps
-
script
// list patterns const list_re = /^\t/gm; // grab state let [lnStart, lnLen] = editor.getSelectedLineRange(); let lnText = editor.getTextInRange(lnStart, lnLen); let [selStart, selLen] = editor.getSelectedRange(); let outdent_lines = (l) => { let lines; if (l.match(list_re)) { lines = l.replace(list_re, ""); } else { lines = l; // return the original string if no tab at the beginning } return lines; } let detabbed_text = outdent_lines(lnText); editor.setTextInRange(lnStart, lnLen, detabbed_text); editor.setSelectedRange(selStart + selLen -1, 0);
Options
-
After Success Nothing Notification Error Log Level Error
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.