33

How can i automate breaking lines (word wrap) in PHPStorm 2.1?

Jess Stone
  • 677
  • 8
  • 21
Benoit
  • 693
  • 2
  • 7
  • 7

9 Answers9

85

Automatic wrap example aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa‌aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa :

This expression has automatic wrap, because I did not press return.

As I understand you want Soft Wraps, when long line is wrapped on screen into multiple lines, but still remains as single line in file.

Soft Wraps

on per file basis
View | Active Editor | Use Soft Wraps

for all files by default
Settings/Preferences | Editor | General | Use soft wraps in editor

Right margin setting

There is also Settings/Preferences | Editor | Code Style | General --> Wrap when typing reaches right margin

But that's different (it will make actual new line).

UPDATE: In current builds IDE can use separate value for right margin per different "language" -- as long as that language has an entry in Code Style settings.


Also keep in mind that any settings from .editorconfig files (if you have such files in your project and EditorConfig plugin is installed & enabled) will override the same from Code Style settings -- it's the nature of the plugin and not a bug (it meant to work this way).

Using EditorConfig support you can configure certain settings that otherwise may not be possible to do via Code Style (e.g. settings for languages/file types that have no separate Code Style entry).

LazyOne
  • 158,824
  • 45
  • 388
  • 391
  • In PHPStorm 4.03 the per-file command is View -> Active Editor -> Use Soft Wraps...guess they added a submenu there somewhere along the line. – VanAlbert Aug 06 '12 at 14:01
  • Thanks for the right margin setting precision, it was driving me crazy recently to have my HTML being broke automatically. – Zachary Dahan Sep 08 '15 at 15:42
  • aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalrighty then. <=automatic wrap also. – clusterBuddy Jul 31 '17 at 06:24
  • That line does not break with a hard return because there's no place to break it. PhpStorm breaks lines at spaces and hyphens, but if there aren't any, it doesn't. This is because the line could be a URL, password, or key that would cause trouble if it had a line break inside. – Bob Ray Sep 17 '21 at 18:33
  • Soft wrap, that was the answer. Thanks. – Andy Apr 25 '22 at 17:55
10
  1. Open Settings
  2. Type "Use Soft Wraps" in search box
  3. In keymap tab right click on "Use Soft Wraps" and add a custom shortcut

You will be able to toggle them with that shortcut

Serdar D.
  • 3,055
  • 1
  • 30
  • 23
8

In PhpStorm 2019.1.3 You should add file type you want to make soft wrapping on it

go to Settings -> Editor -> General -> Soft-wrap files then add any types you want

enter image description here

Mohammed Zayan
  • 859
  • 11
  • 20
2

For wrapping text/code line by deafault: File -> Settings -> Editor -> General -> section "Soft Wraps" -> checkbox "Use soft wraps in editor"

2

In Webstorm 2020.3 i did not found any option for all files by default, but just change the pattern:

for ALL files:

Settings > Editor > General > Soft Warps > Soft-wrap theses files: you can change value to:

*.* (in the other words "ANY file name" and "ANY extension file")

for SOME FILES:

*.php; *.html (Any files with exntension .php OR .html)

LuanLuanLuan
  • 523
  • 5
  • 10
1

simple:

cmd+F8

You can find the list of shortcut by PhpStorm in menu Help -> Default Keymap Reference!

JellyBelly
  • 2,451
  • 2
  • 21
  • 41
  • Thx but I meant "wraps" lines, and not breaking. an idea ? – Benoit Jul 08 '11 at 13:15
  • What do you mean by "wraps"? Can you explain better? – JellyBelly Jul 08 '11 at 13:41
  • automatic wrap ? you know... example : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa : this expression has automatic wrap, cause i did not press return... hope you understand – Benoit Jul 08 '11 at 13:55
  • sorry, but i speak english so so e not understand what do you do with phpStorm! want to replicate the line or phrase? – JellyBelly Jul 08 '11 at 14:06
  • 1
    for some odd reason php storm calls it "soft wrap" where as every other software Ive ever used has called it "Word Wrap". Basically wrap very long line of code/text onto new lines as the reach the end of the screen instead of giving me horizontal scrollbars. – azzy81 Mar 25 '13 at 15:00
0

in phpstorm 2016:

Settings/Preferences | Editor | Code Style | General --> default option-> uncheck wrap on typing
Nur Uddin
  • 1,798
  • 1
  • 28
  • 38
0

To make it automatic

After applying this point:

Use Ctrl + Alt + S to open the settings menu

  1. Select and click Editor

  2. Choose Code Style

  3. Change the default value of the Hard wrap value to 90

  4. Go back to CodeStyle and choose any of the language you work with to make specific changes

5.1 I choose HTML and Select Other and i change the value of Hard wrap at 90 and wrap on typing to Yes

5.2 I choose JavaScript and Select Wrapping and Braces and change the Hard wrap at value to 90 and wrap on typing to Yes

  1. Continue to do it with all other languages you work with

NB: other languages may be at a default values, change it if is not preferable to you

  1. Apply and Ok to save the changes
-1

Using phpstorm 2019.3.4 as well as new and older version :

  1. Use Ctrl + Alt + S to open the settings menu

  2. Select and click Editor

  3. Choose Code Style

  4. Change the default value of the Hard wrap value to 90

  5. Apply and save changes

  6. Press Ctrl + A to highlight and select all your codes in the text editor

  7. Press Ctrl + Alt + L to format your code nicely

Or when using the default settings for Hard wrap at 180 , follow 6 and 7