Questions tagged [whitespace]

Whitespace, or white space, is often used to refer to any combination of spaces, tabs, and new lines which create blank space between text, either horizontally or vertically.

Whitespace, or white space, is often used to refer to any combination of spaces, tabs, and new lines which create blank (or white, originally referring to the background color behind it) space between text, either horizontally or vertically. White space is not represented by a visual character or symbol, but in most cases does occupy space on the page.

Whitespace Characters

The following characters are all defined as being whitespace.

  • U+0009 - Horizontal Tab
  • U+000A - Line Feed
  • U+000B - Vertical Tab
  • U+000C - Form Feed
  • U+000D - Carriage Return
  • U+0020 - Space
  • U+0085 - Next Line
  • U+00A0 - Non-Breaking Space
  • U+1680 - Ogham Space Mark
  • U+180E - Mongolian Vowel Separator
  • U+2000 - EN Quad
  • U+2001 - EM Quad
  • U+2002 - EN Space
  • U+2003 - EM Space
  • U+2004 - Three-per-EM Space
  • U+2005 - Four-per-EM Space
  • U+2006 - Six-per-EM Space
  • U+2007 - Figure Space
  • U+2008 - Punctuation Space
  • U+2009 - Thin Space
  • U+200A - Hair Space
  • U+2028 - Line Separator
  • U+2029 - Paragraph Separator
  • U+202F - Narrow Non-Breaking Space
  • U+205F - Medium Mathematical Space
  • U+3000 - Ideographic Space
4336 questions
84
votes
15 answers

How can strip whitespaces in PHP's variable?

I know this comment PHP.net. I would like to have a similar tool like tr for PHP such that I can run simply tr -d " " "" I run unsuccessfully the function php_strip_whitespace by $tags_trimmed = php_strip_whitespace($tags); I run the regex…
Léo Léopold Hertz 준영
  • 134,464
  • 179
  • 445
  • 697
82
votes
4 answers

Remove whitespace from string in Objective-C

I have a couple of strings. Some have a whitespace in the beginning and some not. I want to check if a string begins with a whitespace and if so remove it.
Crazer
  • 837
  • 1
  • 7
  • 6
79
votes
4 answers

How do I split a string by whitespace and ignoring leading and trailing whitespace into an array of words using a regular expression?

I typically use the following code in JavaScript to split a string by whitespace. "The quick brown fox jumps over the lazy dog.".split(/\s+/); // ["The", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog."] This of course works even…
natlee75
  • 5,097
  • 3
  • 34
  • 39
73
votes
6 answers

How do I delete till non-whitespace in vim?

I'm looking for a command to delete from the cursor to the first non-whitespace character on the same line. I've googled for a while and tried several possibilities. No joy. Does someone out there know how to do this?
Singlestone
  • 2,019
  • 3
  • 16
  • 18
71
votes
3 answers

How do I make Emacs show blank spaces?

How can I make Emacs show blank spaces (like a space, a tab, a line-jump, etc). Many other editors like Kate and Eclipse have this feature and I find it very useful to see when code is indent-broken because of mix of spaces and tabs (particularly…
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
68
votes
7 answers

Is there a way to make whitespace visible in the Xcode editor?

I want the tabs and spaces to be visible in Xcode. Is this possible? I can't find it under preferences.
Steve
68
votes
12 answers

Adding a line break to a UITextView

I have a UITextView that takes an NSString with formatting stringWithUTF8String. It is getting its values from a database and I want the text in the database to be rendered with breaks within the text. I tried using \n to do this but it gets…
Mark Cicero
  • 737
  • 1
  • 6
  • 5
68
votes
7 answers

How to remove trailing whitespaces for multiple files?

Are there any tools / UNIX single liners which would remove trailing whitespaces for multiple files in-place. E.g. one that could be used in the conjunction with find.
Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435
65
votes
3 answers

Specifying Tab-Width?

Is it possible to define the tab-width when whitespace is displayed (say within a
 tag or something)? I can't find anything to do this with CSS, but this seems like it would be a pretty common thing to want to do.
In my case, the tab width is…
Wilco
  • 32,754
  • 49
  • 128
  • 160
65
votes
7 answers

How to create string with multiple spaces in JavaScript

By creating a variable var a = 'something' + ' ' + 'something' I get this value: 'something something'. How can I create a string with multiple spaces on it in JavaScript?
István
  • 5,057
  • 10
  • 38
  • 67
62
votes
14 answers

Why does HTML require that multiple spaces show up as a single space in the browser?

I have long recognized that any set of whitespace in an HTML file will only be displayed as a single space. For instance, this:

Hello. Hello. Hello. Hello. Hello.

displays as: Hello. Hello. Hello. Hello. …
Rudd Zwolinski
  • 26,712
  • 17
  • 57
  • 60
61
votes
8 answers

My diff contains trailing whitespace - how to get rid of it?

I've tried editing a php file in TextWrangler with line endings set to Unix, in NetBeans, and in vim. When I save the diff to a patch and then try to apply it, it gives whitespace errors. When I type git diff I can see ^M at the ends of my lines,…
beth
  • 1,916
  • 4
  • 23
  • 39
60
votes
4 answers

How can I insert vertical blank space into an HTML document?

I am writing a quiz in HTML and I would like to insert a consistent blank vertical space between questions (like one would use vspace{3 cm} in LaTeX). For example:

This is the first question?