How to set word-wrap in VSCode?

hustnzj發表於2022-09-08

Line breaking, also known as word wrapping, is breaking a section of text into lines so that it will fit into the available width of a page, window or other display area.

How to wrap lines automatically in VSCode?

Open Command Palette , type “OFSJ” which is “Preferences: Open Folder Settings (JSON)”. Of course you can choose User Setting or Workspace Setting, but you need to pay attention to the precedence

Type the following settings in the opened json file.

// for all types of files but markdown
"editor.rulers": [80],
"editor.wordWrap": "bounded",
"editor.wordWrapColumn": 80,

From now on, most types of files can wrap at 80 characters. For example, this is a HTML file:

How to set word-wrap in VSCode?

The exception is Markdown files which ships with default language specific settings.

How to set word-wrap in VSCode?

So we need to set wordwrap again for Markdown file.

Add the following line into the JSON setting file:

// for markdown only
"[markdown]": {
  "editor.wordWrap": "bounded",
}

Now all the files are word-wrapped at 80 characters width.

How to set word-wrap in VSCode?

本作品採用《CC 協議》,轉載必須註明作者和本文連結
日拱一卒

相關文章