Skip to content

Instantly share code, notes, and snippets.

@dougalcampbell
Created November 12, 2013 19:34
Show Gist options
  • Select an option

  • Save dougalcampbell/7437263 to your computer and use it in GitHub Desktop.

Select an option

Save dougalcampbell/7437263 to your computer and use it in GitHub Desktop.

Revisions

  1. dougalcampbell created this gist Nov 12, 2013.
    1 change: 1 addition & 0 deletions tabifytextareas.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    javascript:$(document).delegate('textarea', 'keydown', function(e) { var keyCode = e.keyCode || e.which; if (keyCode == 9) { e.preventDefault(); var start = $(this).get(0).selectionStart; var end = $(this).get(0).selectionEnd; $(this).val($(this).val().substring(0, start) + "\t" + $(this).val().substring(end)); $(this).get(0).selectionStart = $(this).get(0).selectionEnd = start + 1; }});void(0);