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
4005 questions
1331
votes
11 answers

Tab key == 4 spaces and auto-indent after curly braces in Vim

How do I make vi-Vim never use tabs (converting spaces to tabs, bad!), makes the tab key == 4 spaces, and automatically indent code after curly brace blocks like Emacs does? Also, how do I save these settings so I never have to input them…
mmcdole
  • 86,293
  • 60
  • 181
  • 221
1155
votes
15 answers

Convert tabs to spaces in Notepad++

How do I convert tabs to spaces in Notepad++? I found a webpage that suggests it's possible, but I couldn't find any information about how to do it. I would like to be able to do that, because some web forms don't respect code with tabs in them.
Helephant
  • 15,502
  • 7
  • 37
  • 35
1135
votes
15 answers

How do I trim whitespace?

Is there a Python function that will trim whitespace (spaces and tabs) from a string? Example: \t example string\t → example string
Chris
  • 20,161
  • 24
  • 68
  • 94
913
votes
21 answers

How do I change Eclipse to use spaces instead of tabs?

By default Eclipse indents with a hard tab character. How do I change it to spaces?
Brian Deacon
  • 19,494
  • 12
  • 36
  • 40
813
votes
23 answers

Make Vim show ALL white spaces as a character

I can't find a way to make Vim show all white spaces as a character. All I found was about tabs, trailing spaces etc.
Matt
735
votes
36 answers

Removing whitespace from strings in Java

I have a string like this: mysz = "name=john age=13 year=2001"; I want to remove the whitespaces in the string. I tried trim() but this removes only whitespaces before and after the whole string. I also tried replaceAll("\\W", "") but then the =…
zyamat
  • 7,371
  • 3
  • 15
  • 5
570
votes
13 answers

How to split a string with any whitespace chars as delimiters

What regex pattern would need I to pass to java.lang.String.split() to split a String into an Array of substrings using all whitespace characters (' ', '\t', '\n', etc.) as delimiters?
mcjabberz
  • 9,498
  • 10
  • 34
  • 36
539
votes
4 answers

Split string on whitespace in Python

I'm looking for the Python equivalent of String str = "many fancy word \nhello \thi"; String whiteSpaceRegex = "\\s"; String[] words = str.split(whiteSpaceRegex); ["many", "fancy", "word", "hello", "hi"]
siamii
  • 20,540
  • 26
  • 86
  • 136
510
votes
13 answers

Show whitespace characters in Visual Studio Code

Is it possible to show whitespace characters, like the space character, in Visual Studio Code? There doesn't appear to be an option for it in the settings.json (though it is an option in Atom.io), and I haven't been able to display whitespace…
429
votes
14 answers

How to auto-remove trailing whitespace in Eclipse?

The question has two parts, one of which I already have the answer for. How to auto-remove trailing whitespace from the entire file being edited? -> Answer: use the AnyEdit plugin, which can be set to do that on any save to the file. How to…
Jan Żankowski
  • 7,866
  • 5
  • 32
  • 46
408
votes
2 answers

Git diff -w ignore whitespace only at start & end of lines

I love to use git diff -w to ignore whitespace differences. But, I just noticed that it ignores even whitespace differences in the middle of lines. How could I only ignore whitespace differences that come at the start (^) or end ($) of lines?
ma11hew28
  • 106,283
  • 107
  • 420
  • 616
388
votes
11 answers

Split by comma and strip whitespace in Python

I have some python code that splits on comma, but doesn't strip the whitespace: >>> string = "blah, lots , of , spaces, here " >>> mylist = string.split(',') >>> print mylist ['blah', ' lots ', ' of ', ' spaces', ' here '] I would rather end…
Mr_Chimp
  • 5,950
  • 5
  • 33
  • 43
380
votes
15 answers

How can I trim leading and trailing white space?

I am having some troubles with leading and trailing white space in a data.frame. For example, I like to take a look at a specific row in a data.frame based on a certain condition: > myDummy[myDummy$country == c("Austria"),c(1,2,3:7,19)] [1]…
mropa
  • 10,364
  • 9
  • 31
  • 29
370
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,496
  • 11
  • 41
  • 73
362
votes
9 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
  • 9,288
  • 13
  • 41
  • 41
1
2 3
99 100