808

When using code files, you typically don't need longer lines to wrap around. However, with .md files this is in fact rather useful. However, I can't seem to find the option to enable word wrap so longer lines will be wrapped.

To reproduce, open Visual Studio Code resized to a small-enough window, and enter the following text in a new document:

This is my test lorem ipsum. This is my test lorem ipsum. This is my test lorem ipsum. This is my test lorem ipsum. This is my test lorem ipsum. This is my test lorem ipsum. This is my test lorem ipsum. This is my test lorem ipsum. This is my test lorem ipsum.
A linebreak before this. 

The effect is this:

Example of missing word wrap

I'm trying to get the horizontal scrollbar to stay away, having line 1 wrap around at the right side of the window.

I've done a few things to answer my own question:

  • Search Stack Overflow: zero results at the time of writing this;
  • Meticulously going through the menu of Visual Studio Code: didn't find it;
  • Using the Command Palette with "wrap": gives no matching commands.

Perhaps it's not possible, and I'd need to file a feature request? Or am I missing something?

Note that I'd like to be able to turn it on and off quickly. For one, @PanagiotisKanavos mentioned in comments this solution to change wrapping behavior in the settings, but I'm looking for a quick command or menu option to do this (much like Notepad++ and Sublime Text 2 have).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Jeroen
  • 60,696
  • 40
  • 206
  • 339
  • 1
    I think this was just added in VS Code 0.3. Check the [list of new features](https://code.visualstudio.com/updates) for wrapping control – Panagiotis Kanavos Jun 24 '15 at 12:07
  • 3
    [This question](http://askubuntu.com/questions/622631/how-to-wrap-text-comments-in-visual-studio-code) from another StackExchange site shows that you can simply add `"editor.wrappingColumn": 0` in your user settings – Panagiotis Kanavos Jun 24 '15 at 12:11
  • 1
    @PanagiotisKanavos Thanks for the suggestion. That would be somewhat of a workaround, because word wrap is typically something I want to switch on/off quickly. I've updated my question accordingly. It may still be useful to turn your comment into an answer though, for others that land here who may be fine with that workaround. – Jeroen Jun 24 '15 at 13:37
  • 3
    Its now "editor.wordWrap": true – DogCoffee Mar 09 '17 at 08:20
  • Related (not duplicate): *[How can I toggle word wrap in Visual Studio?](https://stackoverflow.com/questions/315485)* – Peter Mortensen Nov 14 '17 at 19:36
  • For those using Eclipse Theia or gitpod.io: Go to File -> Settings -> Open Preferences -> editor -> `wordWrap` -> set it to `true`. – koppor Jun 19 '19 at 16:37
  • There are a lot of solutions, if they don't work, then restart your virtual studio code IDE, then it may work. – ulyssis2 Jul 03 '23 at 13:34

26 Answers26

1302

Since v1.0 you can toggle word wrap:

  • with the new command editor.action.toggleWordWrap, or
  • from the View menu (*View** → Toggle Word Wrap), or
  • using the ALT+Z keyboard shortcut (for Mac: +Z).

It can also be controlled with the following settings:

  • editor.wordWrap
  • editor.wordWrapColumn
  • editor.wrappingIndent

Known issues:

  1. renderLineHighlight should highlight the entire logical line

If you'd like these bugs fixed, please vote for them.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Benjamin Pasero
  • 113,622
  • 14
  • 75
  • 54
  • 1
    Completely agree that this should be a thing we can manually enable/disable on a per-window basis. Right now I'm going though a .txt file with a bunch of log entries, and having word-wrap enabled makes it challenging to read. Usually I don't mind it, but in this instance would like it disabled. –  Nov 04 '15 at 10:05
  • 1
    Just implement it as it is currently in Sublime. That's perfect! – Juri Nov 17 '15 at 15:11
  • 2
    @Benjamin, what about 'wrap to window'? That's something I personally use a lot in certain code files (like MarkDown as he said). Personally, I'd love to see three options accessed quickly: Off (No wrapping), Window (wraps to viewable extents) and Specified Column (which would pick up the value in the preferences.) Then be able to assign keyboard shortcuts to flip between those three. – Mark A. Donohoe Feb 24 '16 at 17:52
  • This is no acceptable solution if you need to set `"editor.wrappingColumn": -1` by default. Use case is: I work a lot with code files. Only in some case (*.md files) I must toggle word wrap but cannot! – Marcel Feb 10 '17 at 09:27
  • 2
    For that you can leverage our language specific settings introduced in 1.9 (see http://code.visualstudio.com/updates/v1_9#_settings) – Benjamin Pasero Feb 10 '17 at 10:32
  • Wicked ALT+Z or pressing View > Toggle Word Wrap doesn't do absolutely anything. – Eric Feb 24 '17 at 19:45
  • Please report issues like that to our repository (https://github.com/Microsoft/vscode/) – Benjamin Pasero Feb 25 '17 at 06:57
  • however it's not working for me with big files. only work with very small files. – Sheldon Wei Jan 30 '18 at 07:20
  • editor.wordWrap is a better option to add word wrap for all files. – Amit Kumar Apr 04 '18 at 04:55
  • ALT+Z fires the nVidia GeForce Experience overlay for video capture etc. Only way is via the menu which is acceptable. – Bob Denny Jun 25 '19 at 23:52
  • Alt-Z works on a Lenovo T420 Thinkpad running Ubuntu 18. – mLstudent33 Jan 03 '20 at 23:43
  • NB you can do this on a per file or file type basis by adding `"[markdown]": {"editor.wordWrap": "on"}` this creates a file type override for the setting – S.B.G Feb 06 '20 at 10:30
  • somehow, you can hit alt+z by accident doing some other formatting stuff and the word wrap settings does absolutely nothing with it, you have to find this answer and hit alt+z again, this time on purpose – jave.web Mar 23 '22 at 22:44
  • If you want that word wrap on every session, please change `editor.wordWrap` in `settings` menu. – Dmitriy Ogureckiy Jul 03 '22 at 05:15
76

Go to menu FilePreferencesUser Settings.

It will open up Default Settings and settings.json automatically. Just add the following in the settings.json file and save it. This will overwrite the default settings.

// Place your settings in this file to overwrite the default settings
{ "editor.wrappingColumn": 0 }

Screenshot of settings being edited.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Radha Satam
  • 998
  • 9
  • 11
  • 25
    with latest version its, "editor.wordWrap": "on" is setting above one wont work. – Nitish Mar 21 '17 at 18:52
  • 4
    Yes, this setting was changed in VSCode 1.10. Here's the documentation: https://code.visualstudio.com/updates/v1_10#_word-wrap-settings-redesign – Matt Bierner Apr 05 '17 at 02:18
  • 2
    Open settings.json for me is easiest F1 > backspace key > enter settings.json > find the one in .config – Timo Dec 26 '20 at 20:42
67

wrappingColumn has been deprecated in favour of wordWrap.

Add this line to settings.json to set wordWrap on by default:

"editor.wordWrap": "on" 

or open user settings:

Mac: + ,

Windows: Ctrl + ,

Then search for "wordWrap" or scroll through the 'Commonly Used' settings to find it and select 'on'

enter image description here

Pixelomo
  • 6,373
  • 4
  • 47
  • 57
  • 3
    Thanks for the addition, but don't [the top answer](https://stackoverflow.com/a/31028495/419956) and [this other earlier answer](https://stackoverflow.com/a/45397785/419956) also mention exactly that already? – Jeroen Mar 01 '18 at 10:58
  • 1
    not exactly, they reference wordWrap but I thought my addition would be useful for anyone looking for a simple piece of code to just copy and paste – Pixelomo Mar 02 '18 at 00:15
38

Since version 0.3.0, wrapping has been put in the command palette. You can activate it with Toggle Word Wrap or Alt + Z.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Haroen Viaene
  • 1,329
  • 18
  • 33
  • 2
    Unfortunately this does not seem to get remembered and has to be applied again every time. – clel Oct 06 '21 at 09:43
32

Check out this screenshot (Toogle Word Wrap):

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Nish
  • 695
  • 1
  • 7
  • 14
27

Go to the Preferences tab (menu FileSettings), and then search as “word wrap”. The following animated image is helpful too.

Enter image description here

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

If you want to use text word wrap in your Visual Studio Code editor, you have to press button Alt + Z for text word wrap. Its word wrap is toggled between text wrap or unwrap.

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

Since 1.9, it's possible to select a specific language for word wrap settings (or any settings). You can find this in the command palette under:

Preferences: Configure Language Specific Settings...

Which will take you to your "settings.json" for a selected language where you might include:

"[markdown]": {
  "editor.wordWrapColumn": 100,
  "editor.wordWrap": "wordWrapColumn"
},
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
robstarbuck
  • 6,893
  • 2
  • 41
  • 40
  • How do you get to *"Configure Language Specific Settings"*? – Peter Mortensen Jan 23 '20 at 01:22
  • 1
    One route is from the menu `View => Command Palette...` You can then type "Configure Language Specific Settings..." (or just "Lang set"). The Command Palette is a really good way of finding anything in vscode, it's worth learning the shortcut. – robstarbuck Jan 23 '20 at 13:38
25

Here you go with word-wrap on Visual Studio Code.

16

Using the Command Palette works for this question, but also for many similar other questions:

  1. Press ctrl+shift+p (macOS command+shift+p)
  2. The keyboard shortcut opens the "Command Palette"
  3. Search for "toggle wrap" or just "wrap"
  4. Set your preferences for "Toggle Word Wrap"

Notes:

  • Works for version 1.55.2 and up
  • Default shortcut is alt+z
  • The "Command Palette" will show you the keyboard shortcut for your option too

Screenshot:

top of the VSCode editor with the command palette open and ">toggle wrap" typed, showing the answer with its keyboard shortcut

Jeroen
  • 60,696
  • 40
  • 206
  • 339
Syahidur Rahman
  • 161
  • 1
  • 3
  • for the latest version – Syahidur Rahman Apr 29 '21 at 01:56
  • You can edit your answer if you wished to add "for the latest version" :) – WurmD Apr 29 '21 at 18:44
  • 3
    that default note `alt + z` was really helpful! – amurrell Jan 05 '22 at 23:54
  • I'm the original poster of the question, and for what it's worth this would now be my preferred answer. The reason: the CTRL+SHIFT+P combination opens the 'Command Palette' and _not only_ fixes my original problem, but _also_ nearly all similar features _and_ anno 2023 will teach you the keyboard shortcut for your intended purposes inside the resulting options in the palette! – Jeroen Apr 05 '23 at 06:15
13

I am not sure when it was added, but I'm using v0.10.8 and Alt + Z is the keyboard shortcut for turning word wrap on and off. This satisfies the requirement of "able to turn it on and off quickly".

The setting does not persist after closing Visual Studio Code. To persist, you need to set it through Radha's answer of using the settings.json file...

// Place your settings in this file to overwrite the default settings
{ "editor.wrappingColumn": 0 }
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Hoss
  • 692
  • 1
  • 7
  • 20
9

Word wrap settings redesign

Here are the new word wrap options:

editor.wordWrap: "off" - Lines will never wrap.
editor.wordWrap: "on" - Lines will wrap at viewport width.
editor.wordWrap: "wordWrapColumn" - Lines will wrap at the value of editor.wordWrapColumn.
editor.wordWrap: "bounded" 

Lines will wrap at the minimum of viewport width and the value of editor.wordWrapColumn.

Zoltan Toth
  • 46,981
  • 12
  • 120
  • 134
digish a d
  • 441
  • 1
  • 6
  • 10
  • Thx for the answer. But this info was also already in the top-voted answer. I suggest adding the short bits of explanation for the new options to that answer as an edit. – Jeroen Jul 30 '17 at 09:34
  • 1
    Was looking some clarity regarding the meaning of the different options. I played with the values and it was basically between `boundend` and `on`, in the end I decided to go with `on` as if you have more space in your window it will not wrap, while `bounded` wraps to `editor.wordWrapColumn` (default is `80`) even if there is more space in the window so for me personally `on` the most sensible but it's personal of course. Hope it helps :) – Aldo 'xoen' Giambelluca Feb 05 '19 at 13:16
8

Explained here Language-specific editor settings but specifically:

  1. Ctrl+Shift+P and type "Preferences: Configure Language Specific Settings"
  2. Select the language or add section in the file (start typing "[" to see list of suggestions) or edit section as you like if already there.
  3. If set it to bounded you might need to adjust the editor.wordWrapColumn value to wrap depending on the screen size. With bounded Lines will wrap at the minimum of viewport and editor.wordWrapColumn

Example:


    "editor.wordWrapColumn": 200,
    "[markdown]": {
        "editor.wordWrap": "on",
    },
    "[plaintext]": {
        "editor.wordWrap": "bounded",
    },
    "[typescript]": {
        "editor.tabSize": 2,
        "editor.wordWrap": "off",
    },
  • Should be the accepted answer for users who want to permanently turn it off. Turning it off in preferences has no effect if it is set to `on` in the language preference. – Hari May 07 '21 at 23:44
  • Thanks, I had tried solutions from about 5 other pages before I found this and it finally kicked in. I saw the `"[markdown]": {"editor.wordWrap": "on"},` syntax elsewhere, but couldn't make that work in my settings.json file; it's invalid json. The `Ctrl`+`Shift` + `P` route worked. – John Dec 20 '22 at 19:46
6

This is from the VS Code docs as of May 2020:

Here are the new word wrap options:

editor.wordWrap: "off" - Lines will never wrap.
editor.wordWrap: "on" - Lines will wrap at viewport width.
editor.wordWrap: "wordWrapColumn" - Lines will wrap at the value of editor.wordWrapColumn.
editor.wordWrap: "bounded" - Lines will wrap at the minimum of viewport width and the value of editor.wordWrapColumn.

So for example, if you want to have the lines wrapped at the boundary of the window, you should:

  1. Open settings.json (Hit CTRL+SHIFT+P and type "settings.json")

  2. Put "editor.wordWrap": "bounded" in the json file, like this:

    {
      ... ,
      "editor.wordWrap": "bounded",
      ... ,
    }
    

and then it should work.

General Grievance
  • 4,555
  • 31
  • 31
  • 45
Tim Skov Jacobsen
  • 3,583
  • 4
  • 26
  • 23
5

If it's not working in mac, make sure to tell VScode that you are not using a screen reader.

I had word wrap on and restarted VScode, and it gave me a notification window saying that if I'm in a screenreader, yes or no, and to note that word-wrap does not work in screen readers.

General Grievance
  • 4,555
  • 31
  • 31
  • 45
Royer Adames
  • 868
  • 9
  • 13
4
  • Windows: Ctrl + Shift + press the key "P". Now on the command line, type Toggle Word Wrap and press Enter.
  • Mac: Command + Shift + press the key "P". Now in the command line, type Toggle Word Wrap and press Enter.
Bahman.A
  • 1,166
  • 4
  • 18
  • 33
4

For Dart check "Line length" property in Settings.

Adam Smaka
  • 5,977
  • 3
  • 50
  • 55
3

Accessibility support is on by default and it will override your selected wrapper behavior. So disable Accessibility Support first.

Then choose "on" for the Word Wrap option. You don't need to go into settings.json to enable word wrap.

Picture of the accessibility support option

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
Cihan
  • 69
  • 1
  • 3
  • That should change with VSCode 1.73, Oct. 2022: https://github.com/microsoft/vscode/issues/95428 – VonC Oct 28 '22 at 08:56
3

Step 1: Access to Dart extension settings

enter image description here

Step 2: Find Dart: Line Length, set it to 132 and then save settings enter image description here

Step 3: Press Alt + Shit + F and you will see the lines are wrapping as configured. enter image description here

  • Isn't that _formatting_ instead of _wrapping_ though? – Jeroen Jul 10 '22 at 13:05
  • Formatting (ALT+ SHIFT + F) uses the wrapping configurations. – Carlos Cuellar Jul 11 '22 at 23:43
  • Ah I see what you mean. I was thrown off because my original question (and most answers) was about "_Soft Wrapping_" to prevent scrolling, not so much _hard wrapping_ (in your screenshot there's still a horizontal scroll bar, I was trying to prevent exactly that when writing the question back then). – Jeroen Jul 12 '22 at 08:54
3
  1. Click on Settings in VS Code editor
  2. Search for wordwrap
  3. Select "on" for the Editor Word Wrap as shown in screenshot below

enter image description here

mk23
  • 1,257
  • 1
  • 12
  • 25
2
  • Mac: Code -> Preferences -> Settings -> Type wordwrap in Search settings -> Change Editor: Word Wrap from off to on.

  • Windows: File -> Preferences -> Settings -> Type wordwrap in Search settings -> Change Editor: Word Wrap from off to on.

Daniel Danielecki
  • 8,508
  • 6
  • 68
  • 94
1

If you want a permanent solution for wordwrapping lines, go to menu FilePreferenceSettings and change editor.wordWrap: "on". This will apply always.

However, we usually keep changing our preference to check code. So, I use the Alt + Z key to wrap written code of a file or you can go to menu ViewToggle Word Wrap. This applies whenever you want not always. And again Alt + Z to undo wordwrap (will show the full line in one line).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Abhishek
  • 648
  • 7
  • 8
1

In version 1.52 and above go to File > Preferences > Settings > Text Editor > Diff Editor and change Word Wrap parameter as you wish

rmb_dev
  • 31
  • 6
1

The language-specific example by @Riga is great. For a general setting, I would recommend the following:

"editor.wordWrap": "bounded",
"editor.wordWrapColumn": 90,
"editor.wrappingIndent": "same",

This wraps text if your viewport is smaller than the column limit (90 here) and uses the same indent when wrapping.

Adam Erickson
  • 6,027
  • 2
  • 46
  • 33
0

When opening a huge file showing a notification. The notification guides towards disabling the huge file optimizations (i.e., it instructs how to configure "editor.largeFileOptimizations": false). Once that is done, word wrapping works even for huge files.

SurenSaluka
  • 1,534
  • 3
  • 18
  • 36
0

I am here to for the users who want to disable wrapping but could not succeed.

if disabling doesn't work after you changing the settings around VS code, i.e., the "wrap words" option in control pallete (ctrl+shif+P), or pressing alt+Z, then it is time to look at the extention you have installed.

In my case, i was working with Dart and installed Dart extension. This is what I did. open the extension: enter image description here click the gear icon, choose "extention settings", type "wrap", you will see enter image description here

change it, done!

ulyssis2
  • 1,165
  • 3
  • 10
  • 24