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
1419
votes
12 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
  • 91,488
  • 60
  • 186
  • 222
1248
votes
12 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
  • 16,738
  • 8
  • 39
  • 36
1206
votes
15 answers

How do I trim whitespace?

Is there a Python function that will trim whitespace (spaces and tabs) from a string? So that given input " \t example string\t " becomes "example string".
Chris
  • 21,549
  • 25
  • 71
  • 99
947
votes
23 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
  • 21,384
  • 13
  • 39
  • 41
887
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
820
votes
37 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
  • 8,221
  • 3
  • 17
  • 5
676
votes
14 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…
638
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
  • 23,374
  • 28
  • 93
  • 143
587
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,788
  • 10
  • 36
  • 38
493
votes
19 answers

Efficient way to remove ALL whitespace from String?

I'm calling a REST API and am receiving an XML response back. It returns a list of a workspace names, and I'm writing a quick IsExistingWorkspace() method. Since all workspaces consist of contiguous characters with no whitespace, I'm assuming the…
Corey Ogburn
  • 24,072
  • 31
  • 113
  • 188
476
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
  • 121,420
  • 116
  • 450
  • 651
446
votes
10 answers

How to split by comma and strip white spaces 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
  • 6,658
  • 5
  • 37
  • 47
435
votes
13 answers

How do I escape spaces in path for scp copy in Linux?

I want to copy a file from remote to local system. Now I'm using scp command in linux system. I have some folders or files names are with spaces, when I try to copy that file, it shows the error message: "No such file or directory". I tried: scp…
AlexPandiyan
  • 4,467
  • 2
  • 14
  • 11
431
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
  • 8,690
  • 7
  • 38
  • 52
414
votes
15 answers

How can I trim leading and trailing white space?

I am having some trouble with leading and trailing white space in a data.frame. For example, I 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] codeHelper …
mropa
  • 11,562
  • 10
  • 33
  • 29
1
2 3
99 100