147

I'm editing an XML file with the Eclipse IDE and need to input paragraphs of text. It doesn't seem that eclipse has a line-wrap feature though. Anyone knows if it does or if there's a plugin for that?

2
  • 3
    Do you want soft or hard wrap? Commented Jan 16, 2015 at 10:09
  • Strangely, Sharad Jaiswal asked this question with exactly the same words nine years later on the Eclipse Community Forums: eclipse.org/forums/index.php/t/1098188? Commented Jul 29, 2022 at 12:41

12 Answers 12

130

Update 2016

As mentioned by ralfstx's answer, Eclipse 4.6 M4 Neon (or more) has a word-wrap feature!
(Nov 2015, for release mid 2016). In any editor view, type:

Alt+Shift+Y

https://www.eclipse.org/eclipse/news/4.6/M4/images/word-wrap.png

(Sadik confirms in the comments it works with Eclipse 2019-09)

By default, text editors are opened with word wrap disabled.
This can be changed with the Enable word wrap when opening an editor option on the General > Editors > Text Editors preference page.

Manually toggle word wrap by clicking in the editor window and pressing (Shift+Alt+Y).
On Mac OS X, press (Cmd-Opt-Y). [Updated May 2017]

The famous bug 35779 is finally closed by r/#/c/61972/ last November.

There are however a few new bugs:

As long as we are unable to provide acceptable editor performance for big files after toggling editor word wrap state on, we should make sure users can't set WW preference 1 always on by default and wonder why the editors are slow during resizing/zooming.

(2020) MarcGuay adds in the comments:

If you want the wrapping to be persistent/automatic, the cdhq plugin seems to still work with the 2019-03 version of Eclipse.
After installing you can turn it on via Window->Preferences->Word Wrap.


Update 2014

The de.cdhq.eclipse.wordwrap Word-Wrap Eclipse plug-in just got updated, and does provide good wrapping, as illustrated in the project page:

http://dev.cdhq.de/eclipse/word-wrap/img/01_wrappingOff.gifhttp://dev.cdhq.de/eclipse/word-wrap/img/02_wrappingOn_full.gif


Original answer May 2010

Try the Eclipse Word-Wrap Plug-In here.

Just for the record, while Eclipse Colorer might bring wrapping for xml files, Eclipse has not in general a soft wrapping feature for Text editor.

Soft and hard. Soft will just warp the text at the right window border without adding new line numbers (so there are gaps in the list of numbers when you enable them).

This is one of the most upvoted bugs in Eclipse history: bug 35779 (9 years and counting, 200+ votes)

Update February 2013:

That bug references an old Word wrap plugin, but Oak mentions in his answer (upvoted) a new plugin for recent (Juno+) versions of Eclipse (so 3.8.x, 4.x, may have been seen working with 3.7)
That plugin is from Florian Weßling, who just updated it (March 2013)

Right click in an opened file and select "Toggle Word Wrap" (shortcut ctrl+alt+e)

before
words wrapped

Sign up to request clarification or add additional context in comments.

19 Comments

"Eclipse Word-Wrap Plug-In" works well in latest Eclispe PDT, thanks !
Thanks! The Word-Wrap plugin and the line number fix work for normal txt files including .java files. But they do not work for .xml files. :(
+ 1 for mentioning the soft wrap feature request. Let's upvote that to the heavens.
I can't find the preference at General > Editors > Text Editors in Neon 4.6.0.
@andraaspar yes, that preference was removed. I have updated the answer to reflect that.
|
49

As mentioned in the post by VonC on this same page. Eclipse now has this capability as of 06/2016 Neon.

Try this plugin Eclipse platform plugin

It looks like eclipse only has the ability to do it manually on its own and here are the commands. At that point you must reformat the highlighted text manually.

It's not terribly obvious how to control Eclipse line width and line wrapping in your Java source files. Here's how and where:

Comment width and line wrapping is set in Preferences->Java->Code Style->Formatter, then click on the Edit button and select the Comments tab. I like Line Width for Comments to be 120.

Code line wrapping is set nearby, in Preferences->Java->Code Style- >Formatter, then click on the Edit button and select the Line Wrapping tab. I like a line width of 120 and indent size of 4.

Indentation is set separately, in Preferences->Java->Code Style- >Formatter, then click on the Edit button and select the Indentation tab. I like an indent size of 4, consistent with the Line Wrapping indent setting.

As if that's not enough, you can also set printer margins, tab size, etc, in Preferences>General>Editors>Text Editors where I set the Displayed Tab Width to 4 and Print Margin Column to 120 or more.

You can also check the Show Print Margin box to get a faint vertical line at the printer margin column

6 Comments

I thought that first too, but I guessed that he's more asking for automatic wrapping while editing.
@donpal I think I found a plugin.
it took me 45 minutes of searching to figure out that comments have their own 'width' property ... does MS write this program?
installed this to see if it would recognise markdown files and allow me to word wrap but it doesn't recognise it as one of the 200+ it says it recognises and it doesn't seem to have an easy way to word wrap what it does not recognise and there is nothing much on google about how to get it to work. i have uninstall it.
There is one limitation: this plugin doesn't work in the "Compare" view. Long lines with diff are still painful in eclipse.
|
26

Ctrl+Shift+F will format a file in Eclipse, breaking long lines into multiple lines and nicely word-wrapping comments. You can also highlight just a section of text and format that.

I realize this is not an automatic soft/hard word wrap like the other answers, but I don't think the question was asking for anything fancy.

3 Comments

it will word-wrap assuming your current editor supports word-wrapping. For instance, pydev does not currently (circa jan 2014).
Ctrl+Shift+F does not wrap long comments for me here in Mars.
Ugh.. hard wrap. PS: regarding "anything fancy" I infer from the question's "need to input paragraphs of text" that he doesn't want to press Enter at the end of each line. So I conclude he is looking for soft wrap. Plus, he asked if there's a plugin.
21

Eclipse Neon (4.6), release date June 2016, includes word wrap for text editors. It's disabled by default, and can be activated and deactivated using the key shortcut Alt+Shift+Y (on Mac OS, Cmd-Opt-Y). Some editors also supply a tool bar button for activating word wrap.

See the 4.6 M4 New and Noteworthy

4 Comments

Finally! +1. I have referenced your answer in mine above.
I could not enable this in Mac. Alternative keyboard shortcuts (option or command) did not activate it, and it is not available in Help or any other menu.
In my installation (4.6.2 on Mac), it's alt + cmd + Y
How to activate this for comparison view?
18

The Eclipse Word-Wrap plugin works for any type of file for me.

3 Comments

Perfect. Exactly what I was looking for.
Ive installed your Word Wrap plugin, restarted eclipse but can't figure out the option for Word Wrap. Am I missin something? I'm Using Eclipse Juno, and installed PHP PDT on Juno. Switched to both perspective PHP/Jave EE , but can't seem the option to word wrap even after installing Word Wrap plugin. Can you help me please? Thank you in advance.
Once installed you have you right-click anywhere in the editor and select Toggle Word Wrap, OR press Ctrl-Alt-E.
9

Ahti Kitsik's plugin is mentioned above, but there's a newer plugin by another author that works with newer versions of Eclipse (up to Juno, at least), and also fixed the line numbering issue in the older plugin.

enter image description here

Full installation instructions are at Eclipse version to download the word wrap plug-in

Comments

3

From Bug 35779 - Comment 187:

A workaround, that I use for the last years now, is to use the eclipse wiki markup editor for editing text files. This supports word wrap, and this is enough for me. Maybe this information could be of help to some of you.

Comments

3

In Version: 2019-12 (4.14.0) on MAC

Go to Windows -> Editor -> Toggle Word Wrap

1 Comment

Under Win 10 Alt+shift + Y do the trick, or there is a small icon menu with toggle word wrap, toggle block selection, show white space chars. Here you can select the first. I use version 2020-09 of IDE.
2

Word wrap comes out of the box with Juno now. Right Click on the editor and select the "Word Wrap" option from the dropdown.

2 Comments

@africanherbsman Cannot find the "Word Wrap" option either. Is it specified in a special perspective or in any kind of perspective? I am in the C++ one.
I'm on Default Eclipse Juno Java EE Version, but can't figure out option for WOrd Wrap.
2

In Eclipse v4.7 (Oxygen):

Window menu → Editor → Toggle Word Wrap (Shift+Alt+Y) 

Comments

1

First alpha of eclipse word wrap released!

Got this answer from this post: How can I get word wrap to work in Eclipse PDT for PHP files?

Comments

0

Try AhtiK Eclipse WordWrap, it works for me: http://www.ahtik.com/eclipse-update/

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.