A simple Macro that wraps the current selection in a code block supplied by the requested snippet.
1 2 3 4 5 6 7 8 9 10 11 12 13 14  | var view = ko.views.manager.currentView;
var scimoz = view.scimoz;
var snippet_name = ko.dialogs.prompt('Enter a wrapper snippet name');
if (snippet_name && snippet_name.length > 0) {
  var snpt = ko.abbrev.findAbbrevSnippet(snippet_name);
  if (!/\[\[%(s|w|S|W)\]\]/.test(snpt.value)) {
    ko.dialogs.alert('FAIL: no selection / word under cursor interpolation in this snippet! Are you sure this is is a \'wrapper snippet\'?');
  } else {
    ko.abbrev.insertAbbrevSnippet(snpt);
  }
}
 | 
- add the macro to your toolbox, call it 'wdiv' and bind it to a key combination.
 - create an html snippet like '<div>[%s]</div>' and remember to set it to honour the current indentation.
 - open an html page, select something and hit the key-binding
 - in the prompt, type in 'wdiv'
 - Profit!
 
I have created a bunch of 'wrapper snippets' in my toolbox that allow me to wrap the current selected text in things like try/catch, if/else, html blocks, function, etc.
Download
Copy to clipboard