Tip For Typing Tab

As of December 2003, Ward has modified the Wiki syntax so that beginning a line with an asterisk makes it a list item. See TabRefactoring.

(Auto-numbered lists still need a tab, however.)


If you have trouble typing tabs in EditText (and don't wish to ConvertSpacesToTabs), you can do one of these things: We could list what works with what browser, but it makes more sense for you to just try them.

Contributors: AlexanderBostrom, BradAppleton, SeshKumar & others


Mozilla addon

This could work for mozilla firefox users: https://addons.mozilla.org/en-US/firefox/addon/3955.


JavaScript hacks

What if the following script were added to the edit page as the event handler for the onkeydown event of the TEXTAREA element:

 <script language='javascript'>
  function onKeyDown()
  {
 var e = window.event;
 if (e.keyCode == 9) // tab
 {
 e.srcElement.value = e.srcElement.value + "\t";
 return false;
 }
 return true;
 }
 </script>
The TEXTAREA tag should look like:
 <TEXTAREA NAME="text" ROWS=18 COLS=80 wrap=virtual >

We tested it and it worked fine in IE. However, keep in mind that this adds a TAB character to the end of the text area (not very helpful when editing!) If anyone knows how to get the location of the cursor using DHTML, then something like e.srcElement.value.slice(0,wherecursor) + "\t" + e.srcElement.value.slice(wherecursor) would work. [Guest note: AFAIK, the location of the cursor is not a property of the textarea which is exposed. X.] If also you would push tab to go to next field, this can not do that. My idea is just not to do this. Ether use copy & paste tab or convert space to tab.

Contributors: RodrigoOliveira, CarlosGoncalves?.

Could we make a BookMarklet out of this?

  <script language='javascript'>
function storeCaret (textEl) {
if (textEl.createTextRange)
 textEl.caretPos = document.selection.createRange().duplicate();
}
function insertAtCaret (textEl, text) {
if (textEl.createTextRange && textEl.caretPos) {
 var caretPos = textEl.caretPos;
 caretPos.text =
caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?
text + ' ' : text;
}
else
 textEl.value = text;
}

function onKeyDown(textE2) { var e = window.event; if (e.keyCode == 9) // tab { insertAtCaret(textE2, "\t") return false; } return true; } </script>

<TEXTAREA

onKeyDown(this);"

WRAP="virtual" NAME="text" >

Editado por: Publio

You'll find an other alternative at http://www.siteexperts.com/tips/elements/ts34/page1.asp

-- PerSoderlind

Both Publio's and PerSoderlind's solutions seem to be IE-specific. (See http://msdn.microsoft.com/workshop/browser/mshtml/reference/ifaces/textareaelement/createtextrange.asp just to prove I did some token homework. :) -- JohnLusk, using Mozilla 0.9.6 on Linux. -- Confirmed not to work with Mozilla 1.1 Win32. -- CharlesNepote

In NoteTab, when using the search-and-replace function, the shorthand for a tab is ^T. [Idea - allow the string to be replaced by a tab character to be specified on the editing page.]

I like this idea! It's very easy and you don't need JavaScript! I'll explain you why JavaScriptSucks.

Based on http://www.mozilla.org/projects/ui/accessibility/mozkeylist.html I've determined that Ctrl+Alt+Tab works in Mozilla on OS X. There is no visual feedback though: the insertion point stays put.


An extension called mozex gives you (finally!) a chance to edit textareas, show page sources, etc, outside humongous browsers. Especially people who like vi's should find it very attractive.


This works in IE not Mozilla but is pretty simple to implement:

 /* adds a tab to a textarea when the tab key is pressed, 
 instead of moving focus to next control - 
 insert textarea_tab(this); into " event */
 function textarea_tab(ob){
 //if a tab is pressed
 if (event.keyCode == 9){ //9 = Tab
 //store the current selection / cursor position
 ob.selection = document.selection.createRange();
 //set the selected text (or current cursor position) to a tab
 ob.selection.text = String.fromCharCode(9);
 //cancel the keypress event itself (to prevent the tab from moving focus to the next control)
 event.returnValue = false;
 }
 }


A slight variation of the JavaScript version above works well (and puts the tab at the location of the selection):

 <TEXTAREA document.selection.createRange().text=String.fromCharCode(9);}">


Discussion

It would be nice if Wiki's TextFormattingRules didn't use tabs at all. ConvertSpacesToTabs is a hack, and there are better ways to denote lists (e.g., list items start with one or more * in the first column).

On the other hand, it's not that hard to type tabs. The amount of work it would take to convert all of Wiki's scripts to tabless markup probably isn't worth the resulting benefit.

I may just start using a text editor, maybe even save and revise content before I add it. Think on it a little, even...


Using the new MozillaFirefox with the QuickNote extension, one can copy the text from the EditText box into the QuickNote window (which supports tabs), edit it there, copy and paste back into the main browser text area. Since it's integrated with the browser (Ctrl+F7) once it's installed, it's trivial to use for those cases where it's needed.

In fact, if you just want an insertable TAB character, you can open QuickNote, hit TAB, copy it, and paste it wherever you need it in the browser text area.


EditText of this page (last edited November 22, 2014) or FindPage with title or text search