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:
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:
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).
This question is related to
visual-studio-code
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
.
Explained here Language-specific editor settings but specifically:
"[markdown]": {
"editor.wordWrap": "on",
},
"[plaintext]": {
"editor.wordWrap": "bounded",
},
"[typescript]": {
"editor.tabSize": 2,
"editor.wordWrap": "off",
},
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:
Open settings.json
(Hit CTRL+SHIFT+P and type "settings.json")
Put "editor.wordWrap": "bounded"
in the json file, like this:
{
... ,
"editor.wordWrap": "bounded",
... ,
}
and then it should work.
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.
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"
},
Since version 0.3.0, wrapping has been put in the command palette. You can activate it with Toggle Word Wrap or Alt + Z.
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 }
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.
For Dart check "Line length" property in Settings.
If you want a permanent solution for wordwrapping lines, go to menu File → Preference → Settings 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 View → Toggle Word Wrap. This applies whenever you want not always. And again Alt + Z to undo wordwrap (will show the full line in one line).
Here you go with word-wrap on Visual Studio Code.
Go to menu File → Preferences → User 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 }
In version 1.52 and above go to File > Preferences > Settings > Text Editor > Diff Editor and change Word Wrap parameter as you wish
Source: Stackoverflow.com