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
397
votes
12 answers

Add only non-whitespace changes

I have my text editor to automatically trim trailing whitespace upon saving a file, and I am contributing to an open source project that has severe problems with trailing whitespace. Every time I try to submit a patch I must first ignore all…
Edu Felipe
  • 10,197
  • 13
  • 44
  • 41
388
votes
7 answers

Render a string in HTML and preserve spaces and linebreaks

I have an MVC3 app that has a details page. As part of that I have a description (retrieved from a db) that has spaces and new lines. When it is rendered the new lines and spaces are ignored by the html. I would like to encode those spaces and new…
Dan dot net
  • 6,119
  • 5
  • 28
  • 25
372
votes
14 answers

Trim spaces from end of a NSString

I need to remove spaces from the end of a string. How can I do that? Example: if string is "Hello " it must become "Hello"
Andrea Mario Lufino
  • 7,921
  • 12
  • 47
  • 78
357
votes
11 answers

Why does the Visual Studio editor show dots in blank spaces?

I have a strange bug in the Visual Studio text editor. All my blank spaces are replaced by a "." public class Person { int age; } looks like this public..class..Person.......................... {.................. ..int…
SNA
  • 7,528
  • 12
  • 44
  • 60
345
votes
22 answers

How to replace spaces in file names using a bash script

Can anyone recommend a safe solution to recursively replace spaces with underscores in file and directory names starting from a given root directory? For example: $ tree . |-- a dir | `-- file with spaces.txt `-- b dir |-- another file with…
armandino
  • 17,625
  • 17
  • 69
  • 81
329
votes
6 answers

How to Turn Off Showing Whitespace Characters in Visual Studio IDE

I don't know what I did but I don't know how to get rid of those arrows on the left.
Juan
  • 15,274
  • 23
  • 105
  • 187
312
votes
20 answers

git: fatal: I don't handle protocol '​​http'

I copy and pasted an git clone command from a web page: https://fedorahosted.org/ibus-typing-booster/ I got this: user@host> git clone ​​http://git.fedorahosted.org/git/ibus-typing-booster.git Cloning into 'ibus-typing-booster'... fatal: I don't…
guettli
  • 25,042
  • 81
  • 346
  • 663
298
votes
9 answers

Remove white space below image

In Firefox only my video thumbnails are displaying mysterious 2-3 pixels of white space between the bottom of my image and its border (see below). I've tried everything I can think of in Firebug with no luck. How can I remove this white space?
Ryan
  • 6,027
  • 16
  • 52
  • 89
297
votes
11 answers

Check if string contains only whitespace

How can I test if a string contains only whitespace? Example strings: " " (space, space, space) " \t \n " (space, tab, space, newline, space) "\n\n\n\t\n" (newline, newline, newline, tab, newline)
bodacydo
  • 75,521
  • 93
  • 229
  • 319
269
votes
19 answers

Remove spaces from std::string in C++

What is the preferred way to remove spaces from a string in C++? I could loop through all the characters and build a new string, but is there a better way?
Steve Hanov
  • 11,316
  • 16
  • 62
  • 69
254
votes
12 answers

Ignore whitespace in HTML

Is there anything in HTML/CSS that tells the browser to ignore whitespace completely? So many times when you want to put, say, two images next to each other - you try desperately to keep the HTML readable, but the browser puts a space between…
Paul
  • 9,409
  • 13
  • 64
  • 113
252
votes
15 answers

Remove multiple whitespaces

I'm getting $row['message'] from a MySQL database and I need to remove all whitespace like \n \t and so on. $row['message'] = "This is a Text \n and so on \t Text text."; should be formatted to: $row['message'] = 'This is a Text and so on…
creativz
  • 10,369
  • 13
  • 38
  • 35
248
votes
7 answers

How do I remove leading whitespace in Python?

I have a text string that starts with a number of spaces, varying between 2 & 4. What is the simplest way to remove the leading whitespace? (ie. remove everything before a certain character?) " Example" -> "Example" " Example " -> "Example " "…
James Wanchai
  • 2,861
  • 4
  • 21
  • 16
241
votes
17 answers

Make Git automatically remove trailing white space before committing

I'm using Git with my team and would like to remove white space changes from my diffs, logs, merges, etc. I'm assuming that the easiest way to do this would be for Git to automatically remove trailing white space (and other white space errors) from…
mloughran
  • 11,415
  • 7
  • 28
  • 22
226
votes
8 answers

How can I convert tabs to spaces and vice versa in an existing file?

I cannot figure out how to do this for the life of me apart from doing a find-replace on 4 spaces and converting to tabs (Version 0.10.2). I can't think of an editor/IDE that doesn't have a specific feature to do this. Does VS Code?
Zach Lysobey
  • 14,959
  • 20
  • 95
  • 149