Smart Tab

Posted by jochi, Last update almost 2 years ago

Inserts 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 indent and move the cursor to the end of the line.


  • 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 indent_lines = (l) => {
    	let lines;
    	if (l.match(list_re)) {
    		lines = l.replace(list_re, "\t$1");
    	} else {
    		lines = l.replace(/^/gm,"\t");
    	return lines;
    let tabbed_text = indent_lines(lnText);
    editor.setTextInRange(lnStart, lnLen, tabbed_text);
    editor.setSelectedRange(selStart + 1);


  • 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.