View Full Version : How to set the tab size for a TEXTAREA?

Nov 21st, 2008, 09:11 PM

When paste text from notepad or other editors into a TEXTAREA, we may have tabs in the text in the TEXTAREA.
How can I set the tab size for the TEXTAREA?

Thanks a lot for your helps in advance.

Nov 21st, 2008, 09:32 PM
Not sure on this but...
When you press tab in a text area it will jump to the next element and will not indent as intended.
A workaround is a button that tabs for you on click or a special js box.

Nov 21st, 2008, 09:50 PM
Thank you.

I don't need to press tab in a TEXTAREA.
I need to set the tab size for the text in a TEXTAREA.

Nov 21st, 2008, 09:54 PM
Um, you can't. It's displayed how the OS wants it to be. I don't see why you can't do a search & replace before you paste it in?

Nov 21st, 2008, 10:07 PM

Nov 21st, 2008, 10:17 PM
I don't think that's what he's talking about. I think (at least) that he's talking about the physical tab character (displayed as 8 consecutive spaces on Windows, I think 4 on OS X.) Unless I'm mistaken?

Nov 22nd, 2008, 12:15 AM
I take it that the OP is talking about text that contains tab spaces and is copied and pasted into the textarea, and he wants to have control over these tab spaces when pasting into the textarea.

Ain’t got no solution, though.

Nov 22nd, 2008, 12:16 AM

Thank you.

"I don't see why you can't do a search & replace before you paste it in?"
Replace to what? I still need the tabs(not spaces), but with the size I/users want.

Nov 22nd, 2008, 12:17 AM
Can we have context? You talk about a textarea, but how will it be displayed? What is this?

Nov 22nd, 2008, 01:48 AM
For example, there is a line with a tab in VC++ editor:
____int a;

somebody copied+pasted it into a TEXTAREA in a forum, it might become
________int a;
the tab still there but with longer space.

If replace the tab with 4 spaces the line will look the same as in VC++ editor. However, this method might not work when the tab is not at the start of the line.

Nov 22nd, 2008, 01:58 AM
Does it really matter? I mean, really? At the end of the day, the code is code. All that will happen is that indents are doubled, which isn't really a major thing.

If you're really that fussy (I don't like tabs anyway, due to the platform-dependant rendering), using spaces will solve the problem. They tend not to be collapsed. I can't think of a situation where they would be in code.

body {
font: .875em/1.8 verdana, sans-serif;

for example, will not have spaces collapsed (intial indent + 1.8 to verdana.)

Nov 22nd, 2008, 06:33 AM

Thank you very much!