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
117
votes
5 answers

Sublime Text 2: Trim trailing white space on demand

I know that Sublime Text 2 can delete the trailing white space on files upon saving. When working in a team and commiting a change to a file this tends to produce huge diffs which make peer code review more cumbersome. For that reason I prefer to…
José Luis
  • 1,816
  • 8
  • 24
  • 26
114
votes
4 answers

How to make separator in pandas read_csv more flexible wrt whitespace, for irregular separators?

I need to create a data frame by reading in data from a file, using read_csv method. However, the separators are not very regular: some columns are separated by tabs (\t), other are separated by spaces. Moreover, some columns can be separated by 2…
Roman
  • 124,451
  • 167
  • 349
  • 456
113
votes
17 answers

How to replace multiple white spaces with one white space

Let's say I have a string such as: "Hello how are you doing?" I would like a function that turns multiple spaces into one space. So I would get: "Hello how are you doing?" I know I could use regex or call string s = "Hello how…
Matt
  • 25,943
  • 66
  • 198
  • 303
112
votes
13 answers

Reading string from input with space character?

I'm using Ubuntu and I'm also using Geany and CodeBlock as my IDE. What I'm trying to do is reading a string (like "Barack Obama") and put it in a variable: #include int main(void) { char name[100]; printf("Enter your name: "); …
Hieu Nguyen
  • 1,497
  • 3
  • 12
  • 15
109
votes
2 answers

Regex to match more than 2 white spaces but not new line

I want to replace all more than 2 white spaces in a string but not new lines, I have this regex: \s{2,} but it is also matching new lines. How can I match 2 or more white spaces only and not new lines? I'm using c#
Bruno
  • 1,091
  • 2
  • 7
  • 3
106
votes
3 answers

Extra space under textarea, differs along browsers

There`s some extra space under textarea tag. From 1 to 4 pixels in different browsers. The markup is very simple: …
Roman
  • 1,946
  • 3
  • 20
  • 28
103
votes
11 answers

How do I remove leading whitespace chars from Ruby HEREDOC?

I'm having a problem with a Ruby heredoc i'm trying to make. It's returning the leading whitespace from each line even though i'm including the - operator, which is supposed to suppress all leading whitespace characters. my method looks like this: …
Chris Drappier
  • 5,280
  • 10
  • 40
  • 64
96
votes
4 answers

how to make svn diff show only non-whitespace line changes between two revisions

I can get diffs between two revisions using something like svn diff -r 100:200 > file.diff But the problem is that there are many lines that show up due to change in whitespace. Is there a way to only write those lines that actually change in a…
umar
  • 4,309
  • 9
  • 34
  • 47
93
votes
8 answers

Fastest way to put contents of Set to a single String with words separated by a whitespace?

I have a few Sets and want to transform each of these into a single String where each element of the original Set is separated by a whitespace " ". A naive first approach is doing it like this Set set_1; Set
Lars Andren
  • 8,601
  • 7
  • 41
  • 56
92
votes
11 answers

How do I remove trailing whitespace using a regular expression?

I want to remove trailing white spaces and tabs from my code without removing empty lines. I tried: \s+$ and: ([^\n]*)\s+\r\n But they all removed empty lines too. I guess \s matches end-of-line characters too. UPDATE (2016): Nowadays I automate…
ellockie
  • 3,730
  • 6
  • 42
  • 44
88
votes
1 answer

white-space: nowrap breaks flexbox layout

I have created a responsive layout for an app using Flexbox. The layout calls for a collapsible menu on the left, a block with a header and body in the middle and a toggleable help-pane on the right (there's more to it but that's the basic…
PieBie
  • 3,259
  • 2
  • 18
  • 27
88
votes
7 answers

Tab Vs Space preferences in Vim

Vim is very accommodating when it comes to tab Vs. space preferences. As I understand it, the tabstop setting indicates the width of a tab character. The shiftwidth setting specifies how many columns to increment/decrement when using the << and >>…
nelstrom
  • 18,802
  • 13
  • 54
  • 70
88
votes
3 answers

setting tabwidth to 4 in git show / git diff

At work we are several developers and don't have a code style guide, and some developers indent with tabs, and some others with 4 spaces (luckily noone of the indent with spaces people uses different than 4 spaces). In general this is no (big)…
Carlos Campderrós
  • 22,354
  • 11
  • 51
  • 57
86
votes
4 answers

HTML/CSS - Best practice for preserving white space on certain elements?

What is the best way to preserve white space in HTML? We have a lot of pages that bring down data from our database, and the data may have multiple spaces in it. The rendered HTML elements that hold the data vary from anchor tags (), spans…
contactmatt
  • 18,116
  • 40
  • 128
  • 186
86
votes
4 answers

In Haskell, when do we use in with let?

In the following code, the last phrase I can put an in in front. Will it change anything? Another question: If I decide to put in in front of the last phrase, do I need to indent it? I tried without indenting and hugs complains Last generator in…
McBear Holden
  • 5,741
  • 7
  • 33
  • 55