dacongy
dacongy

Reputation: 2552

eclipse setting questions

1. Can we make eclipse automatically refresh its buffer?

When we make changes to project files behind eclipse's back, eclipse won't update its buffer automatically. Instead, we have to manually click Refresh. When we forget to do so, we might be running old code.

2. Can we make eclipse to eliminate automatically the
   leading whitespaces in source code files?

Auto indention in eclipse is inserting whitespaces to source code files. Each time we leave a line empty, leading whitespaces are left over. Consider the following code:

1 public void f() {
2   // init
3   a = b;
4
5   // do it
6   for (...) { ... }
7 }

After typing line 3, we hit ENTER. At this point, we realize that we want to separate the different logical sections of the code, so we hit ENTER again. It's obviously a reasonable thing to do, but unfortunately there are some leading whitespaces left over on line 4. Source code control tools (e.g., git) are not happy with that. So can we remove them from inside eclipse?

3. Can we save preference settings across workspaces?

Every time I create a new workspace, I need to change the preference settings. For example, I would typically make the fonts bigger. It's sort of redundant. So can I reuse existing settings?

Upvotes: 1

Views: 113

Answers (3)

zeller
zeller

Reputation: 4974

To answer your first and second questions:
1. You can turn on automatic workspace refreshing which will call refresh every 2 seconds or so, I'm lazy to find it so here is a link with the shot of the prefs tab where you can set it.

2.You can set your own code formatting template, also in the preferences. And then add formatting to the save actions. You can easily google how to do these.

The third one is already answered well by Pangea.

Upvotes: 3

Benj
Benj

Reputation: 1204

Through Eclipse preferences menu (editor/appearence), there is a checkbox to remove trailing whitespaces.

If you want to do a (barbarian) backup of your settings, you can zip your workspace (eclipse must be shut down before this).

If you want to save your settings only, you can zip only the eclipse files/folders in the workspace folder, ignoring the source code.

I'm aware with the second method, since I use it weekly .

Upvotes: 0

Aravind Yarram
Aravind Yarram

Reputation: 80166

3. Can we save preference settings across workspaces?

You can export the old workspace preferences and import into new workspace. Another read: Create New Eclipse Workspace - With All Your Old Settings

Upvotes: 3

Related Questions