How can i automate breaking lines (word wrap) in PHPStorm 2.1?
-
Did you check "Wrapping and braces" in settings? – Brice Favre Jul 08 '11 at 09:28
-
yes but it seems to not work in twig files for example.... – Benoit Jul 08 '11 at 13:16
-
So i think this is related to the twig plugin. – Brice Favre Jul 08 '11 at 14:07
9 Answers
Automatic wrap example aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa :
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).

- 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
-
- Open Settings
- Type "Use Soft Wraps" in search box
- In keymap tab right click on "Use Soft Wraps" and add a custom shortcut
You will be able to toggle them with that shortcut

- 3,055
- 1
- 30
- 23
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

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

- 51
- 1
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
)

- 523
- 5
- 10
simple:
cmd+F8
You can find the list of shortcut by PhpStorm in menu Help -> Default Keymap Reference!

- 2,451
- 2
- 21
- 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
-
1for 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
in phpstorm 2016:
Settings/Preferences | Editor | Code Style | General --> default option-> uncheck wrap on typing

- 1,798
- 1
- 28
- 38
To make it automatic
After applying this point:
Use Ctrl + Alt + S to open the settings menu
Select and click Editor
Choose Code Style
Change the default value of the Hard wrap value to 90
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
- 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
- Apply and Ok to save the changes

- 1
- 2
Using phpstorm 2019.3.4 as well as new and older version :
Use Ctrl + Alt + S to open the settings menu
Select and click Editor
Choose Code Style
Change the default value of the Hard wrap value to 90
Apply and save changes
Press Ctrl + A to highlight and select all your codes in the text editor
Press Ctrl + Alt + L to format your code nicely
Or when using the default settings for Hard wrap at 180 , follow 6 and 7

- 1
- 2
-
Just to be sure: this **changes** the content of the files, which might not be needed – Nico Haase Apr 11 '20 at 13:11
-
You need to change the settings of each of the programming language you always work with in the CodeStyle – PAUL OFFEI Apr 15 '20 at 04:00
-
-
Are you sure the OP was looking for wraps to be stored at a given file, or wraps only present in the IDE? – Nico Haase Apr 15 '20 at 06:09
-