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:

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:

foreach( $employas $val ){

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

Fixing the Problem

Regardless 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

 

Advertisements

About Alvin Bunk
Hi, I'm a software developer at Taft College.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: