Click here to Skip to main content
15,888,195 members
Articles / Programming Languages / PHP

Cut & Paste in Eclipse Removes Space

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
14 Apr 2017CPOL1 min read 4.5K  
Cut & Paste in Eclipse Removes Space

Introduction

I do a lot of Symfony PHP development, and I use Eclipse as my IDE. I’ve been using Eclipse for many years, so I don’t want to switch to PHPStorm, even though it’s one of the most popular IDEs used with Symfony and PHP development.

This article is about a problem of auto indentation when using Eclipse to edit code.

The Problem

The problem I experienced, was when I was cutting and pasting a variable in a foreach loop or in a variable definition, the IDE would automatically remove the space(s) to the right of where I pasted.

For example, let’s take this example code:

PHP
foreach( $bad as $val ){

Then I would double-click the “$bad” variable and do a paste and paste “$employ”, and the IDE automatically deletes the space right after “$employ” and the “$employ” and “as” combine. So it ends up looking like this:

PHP
foreach( $employas $val ){

So you should realize the problem. What it is trying to do is auto indentation.

Fixing the Problem

Regardless of whether you are using PHP or C++ or another language, you would do the same thing. In Eclipse, do the following steps:

  1. Select Window > Preferences.
  2. In the Preferences dialog, select PHP (or language you need to change) > Editor > Typing.
  3. In the Typing area and “When pasting” group, uncheck “Adjust indentation”.
  4. Click Apply.

Below is a screenshot for reference:

Auto_indentation

Image 2 Image 3

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Taft College
United States United States
I’m a software developer. Currently I’m working at Taft College as a Programmer.

Comments and Discussions

 
-- There are no messages in this forum --