Eclipse string literal line wrapping - eclipse

When I run the Formatter it indents string literal lines all the way to the last line of the variable name, even if that exceeds the column guide, as shown in this screenshot:
Ideally, I want all of the lines to be wrapped similar to the way the first line is wrapped, with just a couple of tabs (or 1 tab if possible). I've changed all the Formatter settings for assignment and binary expression and it doesn't affect the Formatter's line wrapping behavior.
Is there a way to make Eclipse wrap lines like NetBeans or maybe with some plugin?
Here's what my Formatter settings are for Line Wrapping:

Plugins
Eclipse Colorer
has an "Enhanced and fixed word wrapping mode".
Eclipse Word-Wrap
is dedicated to word wrapping and might do the job.
Customization
Here's how and where you do it in Eclipse: Preferences->Java->Code Style->Formatter, then click the Edit button and select the Comments tab. After that, the same place, you can select the Line Wrapping tab and the Indentation tab. You can also set margins and tab sizes in Preferences>General>Editors>Text Editors by editing the Displayed Tab Width
I'll note that the Eclipse version should be Eclipse Project Neon (4.6) M4 or higher because Eclipse 4.6 came with some updated word wrapping out of the box.

Related

Perl indent doesn't use space

I am using Eclipse Luna. I have installed the Perl EPIC plugin. I want to indent 4 spaces instead of TAB.
I have checked Window -> Preferences -> General -> Editors -> Text Editors -> Insert spaces for tabs, but still when there is need to auto indent a new line, Eclipse still indents with TAB instead of spaces.
How do I change it so EPIC will use spaces instead of tabs for indentation in Perl files?
Late answer but I ran into the same issue, found this post, and subsequently how to change the formatting settings for Perl EPIC in Eclipse.
From the main IDE workspace, click the Window menu and then choose Preferences.
Scroll down to Perl EPIC and expand it in the tree.
Click the Editor entry.
In the right panel under the Appearance tab, you can change your preferences for Insert tabs/spaces on indent and whether or not to use spaces instead of tabs.

Replace spaces with tabs using Eclipse

I downloaded some code from the Internet, and the four-space indentation is bugging the crap out of me. I tried to do a find and replace for "<4 spaces>" and replace it with "\t", but that just replaced all sets of spaces with the string "\t". How would I put a tab in the "replace" box?
Open Window->Preferences from menu bar.
Select Text Editors from tree menu.
Uncheck Insert spaces for tabs.
After that, run Format menu from context menu and save the file:
I figured it out. I just check the box that says "use regular expressions", then use \t.
In answer to the second half of your question:
The reason why people like spaces more than tabs is consistency. If you have your editor set to show tabs as 4 spaces wide, and I have my editor set to show tabs as 8 spaces wide, the code we're writing will look different to each of us. That's okay until our mutual coworker forgets that we're using tabs and starts spacing his lines using 4 spaces. Now his code looks fine to you, but all the indentation is off to me.
Also, what happens when our work decides that lines should be 80 characters long, or 120 characters long? You'll happily code with 4 space tabs, and when it gets to my editor, I suddenly see some of your lines as too long.
Generally, it doesn't matter whether you use spaces or tabs, as long as you (and every person who works on your code) agrees on which to use, and how wide a tab character is.
I use 4 spaces everywhere, because it looks the same on every editor, every repository, when cated, and everywhere else.
Kouhei response is in the right track, but you'll need to change the options of the Java formatter if you want the auto formatter to use spaces (in the preferences, look for Java -> Code Style -> Formatter, create a new style from one of the existing one, and choose "always use spaces"). Then, Ctrl + Shift + F will remove the tabs and insert spaces.
To resolve the issue of tab with space in the Eclipse editor:
Menu Window --> Preferences --> Java --> Code style --> Formatter
Click on configure project specific settings.
Choose the project
Check Enable project-specific settings
Click on New
Mention your profile name --> click OK.
The profile page will be popped up
Choose Space only under tab policy label of the indentation tab.
Click apply and the OK.
Use Ctrl + Shift + F to format a Java class which will replace tab with space.
Eclipse Helios for C++ developers
Instead of changing the default text editor, change the Code Style/Edit -> see pictures

Eclipse stops me from adding superfluous tabs

I was editing a fairly extensive ant xml build file file and tried to add in an extra tab where I thought appropriate. As it happens, the tab shouldn't have been there (if we were following some "rules" on What Looks Pretty In XML).
And as it happened, eclipse refused to let me put the tab there. I tried a few times, and sometimes it would "allow" one extra tab, but v. often it would either
ignore the tab
remove a tab
I know that what eclipse is doing is "right", (in some byzantine sense, because this isn't python, it is an ant xml build file, so the only way it is "right" is from an aesthetics point of view) but I think it is "stupid".
How can i disable this "feature" in eclipse?
I assume you mean the tabulator key (as opposed to the sub-windows, that are also called tabs).
Look up your editor preferences. Things that might help are the settings "insert spaces for tabs", "displayed tab width" and "smart caret positioning at line start and end".
If this doesn't help, try to avoid the XML editor by not opening with double-click, but using "Open With .." -> "Text Editor"

Aptana tab indentation guides

I recently moved from geany to Aptana as I'm working on some bigger projects and felt I would benefit from a full IDE.
One feature I'm really missing is the little grey line every four spaces to help me maintain indentation consistency. Does anything like this exist for Aptana/Eclipse?
get the PDT tools Indent Guide plugin
Under
Preferences -> General -> Editor -> Texteditor you can activate "Show whitespace characters". If you click on "whitespace characters", you can define, which character should be displayed. Here you can active "Tabs". It's not as good as the lines from Notepad++, but better than nothing.
You can set a print margin indicator (vertical line) in Preferences > General > Editors > Text Editors - but this would only be a single line. You could use tabs instead of spaces - there are options to insert spaces when you use the Tab key. In this same menu, you can choose to show whitespace characters, which will help keep your spacing in order. I don't know of any grid options.

Configuring tab space for Eclipse Compare Merge editor

Is there a way to configure tab spaces for Eclipse Compare/Merge editor?
I have the Text Editor to use 2 spaces for tab and "Insert spaces for tabs" but this doesn't seem to take effect in the Compare/Merge editor. It's quite annoying since it's occasionally messing up the indentation in the source code. I guess my other option is to use an external tool but it would be great if this can be configured within Eclipse.
I'm using Indigo SR2 (64-bit)
--
This appears to be a related Eclipse bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=259410
You can choose to ignore whitespaces in the compare editor. Either you right click in the editor and choose Ignore White Space or you set this in eclipses preferences Window -> Preferences -> General -> Compare/Patch -> Ignore White Space