[[Tag]]
Insert or Wrap selected text in double square brackets, to help in writing url actions that contain Drafts placeholder tags like [[Title]] or [[Draft]]

Script key: Insert or Wrap selected text in double square brackets, to help in writing url actions that contain Drafts placeholder tags like [[Title]] or [[Draft]]

Posted by @the_buch

Install

Details

Label [[Tag]]
Voice Over Insert or Wrap selected text in double square brackets, to help in writing url actions that contain Drafts placeholder tags like [[Title]] or [[Draft]]
Script
// Wrap selected text in square brackets, or insert open and closing brackets, with cursor in between, if no selection made already.
// based on: Apply Markdown emphasis to selection, or insert * if no selection

var sel = getSelectedText();
var selRange = getSelectedRange();

if (!sel || sel.length == 0) {
  setSelectedText("[[]]");
  setSelectedRange(selRange[0]+2,0);
}
else {
  setSelectedText("[["+sel+"]]");
  setSelectedRange(selRange[0]+selRange[1]+2,0);
}

Advanced

Keyboard shortcut None
Hide key Yes

Discussion

comments powered by Disqus