233

How can I enable word wrapping in PhpStorm?

I need to enable it only for some of my files (with extension .txt). Is it possible?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
ozahorulia
  • 9,798
  • 8
  • 48
  • 72
  • 10
    It's a shame that you can't specifically set it to soft wrap for certain file types. I only ever want to wrap if it's a HTML file, and it would be so much handier if I could set it to do that automatically instead of having to click through the menu each time. – Maccath Dec 10 '12 at 15:51
  • 1
    @Maccath it appears you can do that now. See the "soft-wrap files" setting in PHPStorm. – reformed Mar 03 '20 at 22:02

13 Answers13

470

For all files (default setting for opened files): Settings/PreferencesEditorGeneralUse soft wraps in editor. You can now specify file names/extensions where this option will be enabled by default:

Enter image description here


For the currently opened file in the editor: menu → ViewActive EditorUse Soft Wraps (Note: I've assigned custom Ctrl + Alt + R + shortcut for that)

Enter image description here

For quite a while (since v2016 or so) you can also access this option via the context menu for the editor gutter area (the area with line numbers on the left side of the editor):

Enter image description here

(Note: I have customised this menu quite a bit; by default it has much less items here)


Search Everywhere (Shift 2x times) or menu HelpFind Action... (Ctrl + Shift + A on Windows using the Default keymap) can also be used to quickly change this option (instead of going into Settings/Preferences).

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
LazyOne
  • 158,824
  • 45
  • 388
  • 391
  • 133
    right click on the left gutter (line numbers area) and choose Soft Wraps. a ver quick way to enable soft wraps per file – trve.fahad Sep 24 '14 at 14:03
  • File > Settings > Editor > Use Soft wraps in Editor. – pavanw3b Jan 15 '15 at 13:08
  • 4
    File > Settings > Editor > General > "Use soft wraps in editor" – Ryan Sep 05 '15 at 19:58
  • @Ryan that option does not seem to exist anymore. Under **General** the option is not there. – JGallardo Oct 05 '15 at 19:49
  • It is there for me, phpStorm v9.0.2 on ubuntu – Ryan Oct 06 '15 at 04:16
  • 1
    phpStorm for Mac v10.0: **PhpStorm** > Preferences > Editor > Use Soft wraps in Editor (as opposed to under the File menu) – bullcitydave Nov 09 '15 at 18:09
  • I am using PHP Storm on a Mac, 2017.3.4 and for me soft wraps only works in presentation mode. – Daniel Feb 27 '18 at 15:35
  • @dan No idea unfortunately (Windows user here). As far as I'm aware it works (saw no such tickets/complaints). The only other thing -- it may just not remember the setting when you setup to have only 1 tab opened at a time... so when switching between files it forgets the option... – LazyOne Feb 27 '18 at 15:50
  • Or just tap Left Shift key twice and type "soft wraps" and I will find if for You. – Eryk Wróbel May 14 '19 at 05:58
56

You have to enable Soft Wraps. Find that option through this path.

Menu ViewActive EditorUse Soft Wraps

Wrap words in PhpStorm

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
JGallardo
  • 11,074
  • 10
  • 82
  • 96
22

Right click on the line number area and choose:

Soft-Wrap All Files or Soft-Wrap Current File, i.e.:

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Pedro Lobito
  • 94,083
  • 31
  • 258
  • 268
16
  • Menu FileSettingsEditorUse soft wraps in editor: to turn them on for all files by default.

  • Menu FileSettingsCode StyleGeneralWrap when typing reaches right margin

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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Hueston Rido
  • 809
  • 1
  • 11
  • 16
  • 2
    this helped me out. It was driving me mad with the editor auto wrapping my code when I didnt want it to. I couldnt find the option but this helped so ty ^^. – azzy81 Apr 23 '13 at 15:16
  • This must be really old, i could not find it – JGallardo Oct 05 '15 at 19:46
11

In addition to Settings -> Editor -> Use soft wraps in editor I recommend Use soft wraps in console and Use custom soft wraps indent with a setting of 4 to make the wraps indented to match the line they started on.

Steve Putala
  • 181
  • 2
  • 5
11

In PhpStorm 2019.1.3, it is possible to enable soft wrap for some file types only.

enter image description here

Sithu
  • 4,752
  • 9
  • 64
  • 110
10

In PhpStorm 2019.1.3, you should add the file type you want to make soft wrapping on.

Go to SettingsEditorGeneralSoft-wrap files, and then add any types you want:

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Mohammed Zayan
  • 859
  • 11
  • 20
6

You may also want to consider the Wrap to Column plugin, which implements the equivalent to Alt + Q in Emacs and gq in Vim. This may be preferable to having very long lines that are wrapped by the editor.

This plugin can be installed from any IntelliJ IDEA-based IDE by searching for Wrap to Column.

It has the additional benefit that you can choose to wrap only sections of text that you want :-)

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Andrew Mao
  • 35,740
  • 23
  • 143
  • 224
6

If using PhpStorm 2019 and higher

PhpStorm word wrapping settings screenshot

Menu FileSettingsEditorGeneral.

There is the 'Soft-wrap files' input under the 'Soft Wraps' Header.

*.md; *.txt; *.rst; .adoc;

Add the file types to this field in which files you want them to be used.

*.md; *.txt; .rst; .adoc;.php;.js

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Emrah Tuncel
  • 678
  • 8
  • 13
3

For word wrapping in PhpStorm 2019.1.3, just follow below steps:

From the top navigation menu:

ViewActive EditorSoft-Wrap

That's it so simple.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
2

WebStorm 10.0.4

For wrapping text/code line by default, but for all types of file: menu FileSettingsEditorGeneral → section "Soft Wraps" → checkbox "Use soft wraps in editor".

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
0

I want to soft-wrap .php files. Putting that in the allowed list still was not working. (For a screenshot, see Mohammed Zayan's answer.)

I entered *.* there, allowing all the files (I am fine with that) and soft wrap worked fine.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Sohel Ahmed Mesaniya
  • 3,344
  • 1
  • 23
  • 29
-1

For word wrapping in PhpStorm:

  1. Select File from the menu
  2. From File select Setting
  3. From Setting, select Editor
  4. Select General from Editor
  5. In general, checked Use soft wraps in editor from the Soft wraps section
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Miraj Khandaker
  • 772
  • 10
  • 11