179

How would be possible to assign a shortcut for word wrap like as sublime text do? i.e. if the code line is too long it should be automatically break to the next line. wikipedia.org.org/Word_wrap

This code should be wrapped out

Sayat Satybald
  • 6,300
  • 5
  • 35
  • 52
  • Maybe I didn't understand you correctly. If you want to format the code, depending on the key-bindings you can automatically format the code. Eclipse-binding: Shift+Ctrl+F. And if you edit a string, just press inside and it will generate the code to concat the string. Did you mean that? – hgoebl Apr 11 '14 at 06:11
  • 1
    Well, yes ENTER will solve my problem but I won't be able to hit enter on each line. Besides, if someone else open this file on different monitor it would be an ugly mess. I want to make IDE such line breaks automatic. – Sayat Satybald Apr 11 '14 at 08:44
  • You can't have line breaks in intellij that are only visible in your monitor - you need to reformat the text so that you have hard line breaks. just use ctrl-alt-enter, ctrl-enter, or whatever. – vikingsteve Apr 11 '14 at 08:48

13 Answers13

285

I think "soft wrap" might be what you're after. It's read-only, i.e. does not change the characters in the file, it only wraps what you see on screen.

settings soft wrap Intellij >= 14.1.4: As pointed out by looper in the comments, the options are under File > Settings > Editor > General - under the Virtual Space or Soft Wraps sub-group.

Intellij < 14.1.4: Look under File > Settings > Editor > Virtual Space. It doesn't have a shortcut by default, but you can assign one in the keymap.

AndroidStudio >= 1.4.1: the options are under File > Settings > Editor > General - under the Soft Wraps sub-group.

You can also right click the gutter (the vertical bar where line number is shown) and select "Use Soft wraps" - thanks to Bajal for comment. gutter soft wrap

To assign a shortcut for toggling softwrap: Look under File > Settings > Keymap, search for "softwrap", then assign your preferred shortcut.

Shorn
  • 19,077
  • 15
  • 90
  • 168
  • 2
    In the current version of IntelliJ (14.1.4), the soft-wrapping option is located under Editor -> General. – looper Aug 28 '15 at 20:43
  • 39
    One can also right click the gutter (the vertical bar where line number is shown) and select "Use Soft wraps" [15.0.1] – Bajal Jan 25 '16 at 17:36
  • 3
    (In Community Edition 2016+) go : IntelliJ IDEA>Preferences >Editor>General: select options "Use soft wraps in editor" and "Use original line's indent for wrapped parts" – Alferd Nobel Apr 01 '16 at 23:18
  • Thank you! I could only find the Active Editor soft wrap and this was driving me insane. – Allison Apr 19 '18 at 06:59
  • 2
    In IntelliJ IDEA 2018.2 on mac, 'Use soft wraps' is under View -> Active Editor – user674669 Jul 06 '18 at 19:18
  • But soft-wrap is not an answer to this question! – ACV Dec 05 '20 at 23:57
11

[ctrl+alt+s] or File->settings to open settings dialogue.

Search for code style. its under project settings.

In code style, General check

wrap when typing reaches margin

That will give you wrapping of code.

Dineshkumar
  • 4,165
  • 5
  • 29
  • 43
  • 1
    Thanks for suggestion but I'm basically wanting it for reading a code. Not while editing or writing a new one. – Sayat Satybald Apr 12 '14 at 04:07
  • 1
    Was this option renamed? I can no longer find it. – Pieter Aug 19 '16 at 08:34
  • An unfortunate side effect when using this is that when typing in a URL, the code wrapped on the period of a URL which basically made the URL no longer valid., so I had to turn this off. – PatS Oct 18 '20 at 22:19
9

One can also right click the gutter (the vertical bar where line number is shown) and select "Use Soft wraps" - thanks to Bajal for comment.

This is the easiest way, and i found it in comments. I think it should be an answer so everybody can see it easily.

acpuma
  • 479
  • 5
  • 15
8

In order to wrap text in the code editor in IntelliJ IDEA 2020 follow these steps:

  1. Crtl + Shift + "A" OR Help -> Find Action
  2. Enter: "wrap" into text box
  3. Toggle: View | Active Editor Soft-Wrap "ON"

Image of Toggle Switch in Menu

Ardent Coder
  • 3,777
  • 9
  • 27
  • 53
Noah PG
  • 151
  • 2
  • 3
6

In the Community Edition, Do Following:

File >> Settings >> Editor >> Code Style >> Java

Go to Wrapping And Braces Tab.

Set the "Right margin (columns)" option with number of columns you would like as line wrapping point. Set "Wrap on typing" to YES.

Don't forget to apply the changes before you click Ok.

AlexW
  • 896
  • 7
  • 9
Vishal
  • 1,963
  • 2
  • 20
  • 23
4

For IntelliJ IDEA Version: 2019.3

  1. Go to File > Settings

  2. A new window will appear

  3. Select Editor > General

Navigate to Soft Wraps section, check the box, and using a semi-colon as the delimeter, * and ? as wildcards, add the desired file-extensions. Select Apply and you are good to go.

Screenshot of Settings window

4

Right click anywhere on the number of lines bar and click soft-wrap

enter image description here

Or you can just go to View -> Active Editor -> Soft-Wrap

Skidee
  • 563
  • 5
  • 8
3

The answer to this question is:

Use the option Ensure right margin is not exceeded - the bottom option in the screenshot:

enter image description here

ACV
  • 9,964
  • 5
  • 76
  • 81
2

(In Community Edition 2016+) go : IntelliJ IDEA>Preferences >Editor>General: select options "Use soft wraps in editor" and "Use original line's indent for wrapped parts"

Alferd Nobel
  • 3,185
  • 2
  • 30
  • 35
1

OS X 10.8 IntelliJ Idea 15.0.5: IntelliJ IDEA Menu/Preferences/Editor/General/Soft Wraps

Gyuri
  • 4,548
  • 4
  • 34
  • 44
1

The gutter's context menu has a soft wrap option. Right-click on the gutter located to the far left of the editor to reveal the menu

enter image description here

Testilla
  • 602
  • 8
  • 21
0

It can help. Thats the solution I have found, when I was trying the wrap the codelines, in the code-editor, when I was decreasing/increasing(stretching) the window-code-editor.

enter image description here

GtdDev
  • 748
  • 6
  • 14
0

It helped me adding " *.java" after " *.adoc;" because in "Settings", then "General" and then " Soft-wrap these files:" I had only " *.md; *.txt; *.rst; *.adoc ". If after that you add "; *.java" your long java code will be wrapped to a new line. Thx for the screens. It helped me a lot.