Questions tagged [spaces]

The space character, `U+0020`, used to separate words/tokens in most natural and programming languages.

The space character, U+0020, used to separate words/tokens in most natural and programming languages. Space is a whitespace character.

Spaces are frequently of concern to programmers in the context of languages with significant whitespace (e.g. Python), source code indentation, and separating tokens. Separating tokens correctly is important for shell scripts, URIs, file names/paths, text processing, and string formatting. Questions regarding all of these areas are common on Stack Overflow, as spaces appearing unexpectedly can cause unexpected behavior whose source is not immediately obvious.

"Spaces" may also refer to the virtual desktop functionality of Mac OS X, first referred to as "Spaces" in OS X 10.5.

1024 questions
762
votes
4 answers

How do I strip all spaces out of a string in PHP?

How can I strip / remove all spaces of a string in PHP? I have a string like $string = "this is my string"; The output should be "thisismystring" How can I do that?
streetparade
  • 32,000
  • 37
  • 101
  • 123
476
votes
21 answers

How to run an EXE file in PowerShell with parameters with spaces and quotes

How do you run the following command in PowerShell? C:\Program Files\IIS\Microsoft Web Deploy\msdeploy.exe -verb:sync -source:dbfullsql="Data Source=mysource;Integrated Security=false;User ID=sa;Pwd=sapass!;Database=mydb;" -dest:dbfullsql="Data…
Vans
  • 4,769
  • 2
  • 16
  • 3
443
votes
10 answers

Echo tab characters in bash script

How do I echo one or more tab characters using a bash script? When I run this code res=' 'x # res = "\t\tx" echo '['$res']' # expect [\t\tx] I get this res=[ x] # that is [x]
kalyanji
  • 4,608
  • 2
  • 17
  • 6
295
votes
19 answers

How can I convert tabs to spaces in every file of a directory?

How can I convert tabs to spaces in every file of a directory (possibly recursively)? Also, is there a way of setting the number of spaces per tab?
cnd
  • 32,616
  • 62
  • 183
  • 313
251
votes
13 answers

Visual Studio Code - Convert spaces to tabs

I have both TypeScript and HTML files in my project, in both files tabs are converted to spaces. I want to turn the auto-conversion off and make sure that my project has only tabs. Edit: With this setting it seems to work in HTML files but not in…
Matan Yadaev
  • 3,018
  • 3
  • 19
  • 21
236
votes
14 answers

How to strip all whitespace from string

How do I strip all the spaces in a python string? For example, I want a string like strip my spaces to be turned into stripmyspaces, but I cannot seem to accomplish that with strip(): >>> 'strip my spaces'.strip() 'strip my spaces'
wrongusername
  • 18,564
  • 40
  • 130
  • 214
226
votes
11 answers

Sublime Text 3, convert spaces to tabs

I know there are a lot of posts about this, but I couldn´t get it to work. I use tabs for coding. Is there a way, to convert always spaces to tabs? I.e. on open and on Save files? Anyone got an idea? // edit: My desire is to do this automatically!…
chris
  • 4,827
  • 6
  • 35
  • 53
182
votes
5 answers

Show SOME invisible/whitespace characters in Eclipse

A long while back I transitioned to doing all my web application development in Eclipse from BBEdit. But I miss one little feature from BBEdit. I used to be able to show invisible characters like tabs but not show other invisibles like spaces. I…
bryan kennedy
  • 6,969
  • 5
  • 43
  • 64
135
votes
10 answers

Can you make valid Makefiles without tab characters?

target: dependencies command1 command2 On my system (Mac OS X), make seems to require that that Makefiles have a tab character preceding the the content of each command line, or it throws a syntax error. This is an annoyance when creating…
xyz
  • 27,223
  • 29
  • 105
  • 125
125
votes
11 answers

Linux - Replacing spaces in the file names

I have a number of files in a folder, and I want to replace every space character in all file names with underscores. How can I achieve this?
Mithun Sreedharan
  • 49,883
  • 70
  • 181
  • 236
125
votes
6 answers

How do I convert a list into a string with spaces in Python?

How can I convert a list into a space-separated string in Python? For example, I want to convert this list: my_list = ["how", "are", "you"] into the string "how are you". The spaces are important. I don't want to get "howareyou".
user1653402
  • 1,363
  • 3
  • 9
  • 7
96
votes
7 answers

How do I set up Vim autoindentation properly for editing Python files?

I've trouble setting up Vim (7.1.xxx) for editing Python files (*.py). Indenting seems to be broken (optimal 4 spaces). I've followed some tutorials I found via Google. Still no effect :/ Please help.
M_1
  • 2,135
  • 4
  • 21
  • 24
96
votes
11 answers

How do you recursively unzip archives in a directory and its subdirectories from the Unix command-line?

The unzip command doesn't have an option for recursively unzipping archives. If I have the following directory structure and archives: /Mother/Loving.zip /Scurvy/Sea Dogs.zip /Scurvy/Cures/Limes.zip And I want to unzip all of the archives into…
chuckrector
  • 1,471
  • 1
  • 12
  • 9
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
67
votes
7 answers

Auto-convert tab to 4 spaces in TextWrangler?

Is there a preference in Textwrangler to redefine a tab as 4 spaces? In Vim this is set expandtab in the vimrc, but I don't know how to set it in TW besides clicking "Detab" when I'm done editing the document. Thanks, Kevin
Kevin Burke
  • 61,194
  • 76
  • 188
  • 305
1
2 3
68 69