jQuery(function($) {

   /* tab insertion handling */
   $('#code').keydown(function(e) {
      if (e.keyCode == 9 && !e.ctrlKey && !e.altKey) {
         if (this.setSelectionRange) {
            var start = this.selectionStart;
            var end = this.selectionEnd;
            var top = this.scrollTop;
            this.value = this.value.slice(0, start) + '\t' + this.value.slice(end);
            this.setSelectionRange(start + 1, start + 1);
            this.scrollTop = top;
            e.preventDefault();
         }
         else if (document.selection.createRange) {
            this.selection = document.selection.createRange();
            this.selection.text = '\t';
            e.returnValue = false;
         }
      }
   })

   $('#paste').click(function(e) {
      var doc = {};
      doc.title = $('#title').val().trim();
      doc.content = $('#code').val().trim();
      var tags = $('#tags').val().split(',');
      doc.tags = tags.map(function(t) {return t.trim()});
      $Couch.create(doc, './ddoc/_update/create').done(function (data) {
            window.location.pathname += data._id;
      })
      return false;
      //e.preventDefault();
   })

})

@@ -29,26 +29,29 @@
 tab 
-insertion handling
+handling - gemo style
  */%0A
@@ -300,24 +300,326 @@
 .scrollTop;%0A
+            var selected = this.value.slice(start, end);%0A            if (e.shiftKey) %7B%0A               // deindent%0A               var replacement = selected.replace(/%5E%5Ct/gm, '');%0A            %7D else %7B%0A               // indent%0A               var replacement = selected.replace(/%5E/gm, '%5Ct');%0A            %7D%0A
             
@@ -660,20 +660,27 @@
 tart) + 
-'%5Ct'
+replacement
  + this.
@@ -741,23 +741,53 @@
 tart
- + 1, start + 1
+, end + replacement.length - selected.length 
 );%0A 

Indent and deindent selected block of text - gemo style