Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I switch word wrap on and off in Visual Studio Code?

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).

like image 586
Jeroen Avatar asked Jun 24 '15 11:06

Jeroen


People also ask

How do you turn on word wrap in VS Code?

wordWrap": "on" You can toggle word wrap for the VS Code session with ⌥Z (Windows, Linux Alt+Z).

Why word wrap is not working in VS Code?

Go to File->Preferences->Settings. Set the workspace tab (but it's the same with User tab) Set the editor: Word Wrap settings to wordWrapColumn. Set the Editor: Word Wrap Column to 80.

How do I turn off word wrap?

Right-click the control for which you want to enable or disable text wrapping, and then click Control Properties on the shortcut menu. Click the Display tab. Select or clear the Wrap text check box.


1 Answers

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.

like image 67
Benjamin Pasero Avatar answered Oct 01 '22 22:10

Benjamin Pasero