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
223
votes
2 answers

How to display hidden characters by default (ZERO WIDTH SPACE ie. ​)

I just lost part of my weekend because of this ... joker - zero width space. I just used some snippets from google groups and didn't recognize that there are doubled characters, because Idea (11) didn't show them, which was causing problems with…
biesior
  • 55,576
  • 10
  • 125
  • 182
222
votes
14 answers

How can you automatically remove trailing whitespace in vim

I am getting 'trailing whitespace' errors trying to commit some files in Git. I want to remove these trailing whitespace characters automatically right before I save Python files. Can you configure Vim to do this? If so, how?
Paul D. Eden
  • 19,939
  • 18
  • 59
  • 63
222
votes
16 answers

How to put space character into a string name in XML?

i have defined some strings in the strings.xml file. Now I need to put some extra space between some numbers in the string. When I type extra space characters this is not showing on the application though. Before: -4,…
Andreas
  • 2,243
  • 2
  • 14
  • 7
220
votes
3 answers

Merging without whitespace conflicts

I've got a problem, where a large commit which changes about a thousand lines of code, removing whitespace from the end of lines and removing spaces before tabs. There are also about 50 pull requests for this project, in which all will get…
callumacrae
  • 8,185
  • 8
  • 32
  • 49
203
votes
40 answers

How do I trim leading/trailing whitespace in a standard way?

Is there a clean, preferably standard method of trimming leading and trailing whitespace from a string in C? I'd roll my own, but I would think this is a common problem with an equally common solution.
coledot
  • 2,646
  • 3
  • 19
  • 17
202
votes
6 answers

Coloring white space in git-diff's output

Regarding code formatting I'm kind of purist :). I very often remove unnecessary white spaces (lines with only ws, ws at the end of lines etc). I even have set vim to show that kind of lines colored to red. My problem is that using git-diff I often…
radarek
  • 2,478
  • 2
  • 17
  • 12
178
votes
11 answers

How do you allow spaces to be entered using scanf?

Using the following code: char *name = malloc(sizeof(char) + 256); printf("What is your name? "); scanf("%s", name); printf("Hello %s. Nice to meet you.\n", name); A user can enter their name but when they enter a name with a space like Lucas…
Kredns
  • 36,461
  • 52
  • 152
  • 203
173
votes
6 answers

Providing white space in a Swing GUI

A GUI with no white space appears 'crowded'. How can I provide white space without resorting to explicitly setting the position or size of…
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
171
votes
4 answers

How can I determine if a String is non-null and not only whitespace in Groovy?

Groovy adds the isAllWhitespace() method to Strings, which is great, but there doesn't seem to be a good way of determining if a String has something other than just white space in it. The best I've been able to come up with is: myString &&…
cdeszaq
  • 30,869
  • 25
  • 117
  • 173
168
votes
13 answers

Add vertical whitespace using Twitter Bootstrap?

What's the best way to add vertical whitespace using Twitter's Bootstrap? For example, let's say that I am creating a landing page and would like a bit (100px) of blank whitespace above and below a certain button. Obviously, I could create a…
Ryan
  • 10,798
  • 11
  • 46
  • 60
166
votes
9 answers

How can I check if string contains characters & whitespace, not just whitespace?

What is the best way to check if a string contains only whitespace? The string is allowed to contain characters combined with whitespace, but not just whitespace.
patad
  • 9,364
  • 11
  • 38
  • 44
163
votes
5 answers

Setting Vim whitespace preferences by filetype

At my work, I am required to follow the house style for indentation, which goes as follows: 2 spaces when coding html and ruby tabs when coding javascript, with tabwidth=4 recommended What is the best way to specify different whitespace…
nelstrom
  • 18,802
  • 13
  • 54
  • 70
161
votes
7 answers

Avoid line break between html elements

I have this element:  +34 666 66 66 66 I was hoping to keep this into a single line, but this is what I get: As you can see, flag and telephone number are in separate lines. The…
blueFast
  • 41,341
  • 63
  • 198
  • 344
155
votes
16 answers

How do I check that a Java String is not all whitespaces?

I want to check that Java String or character array is not just made up of whitespaces, using Java? This is a very similar question except it's Javascript: How can I check if string contains characters & whitespace, not just whitespace? EDIT: I…
Ankur
  • 50,282
  • 110
  • 242
  • 312
151
votes
11 answers

Check if a string has white space

I'm trying to check if a string has white space. I found this function but it doesn't seem to be working: function hasWhiteSpace(s) { var reWhiteSpace = new RegExp("/^\s+$/"); // Check for white space if (reWhiteSpace.test(s)) { …
Abs
  • 56,052
  • 101
  • 275
  • 409