How To enforce Word Wrap for a language in VSCode

This article was published on Apr 20, 2022, and takes approximately a minute to read.

Every time I open a .md file, it's set up by default to "Word Wrap" the content.

I don't have anything set up in my preferences, so maybe one of my markdown plugins enables that for me automatically.

However, when I open a .mdx file isn't enabled by default.

After turning word wrap a dozen times, I got fed up and decided to fix that once and for all.

We need to go into our settings by hitting cmd + shift + p (or ctrl in Windows/Linux environment) and type Preferences.

Then, we click to open it as json.

This file will contain any customization you do to your VSCode.

If we add the options at the root level, they'll be applied to every file from every extension.

For having global configs tweaked for specific languages, we can add the language like this:

{
  // Global configs
  "[mdx]": {
    // add overrides
  }
}

Then, the configuration related to the Word Wrap is named by editor.wordWrap. We have to configure that to be constantly on:

{
  // Global configs
  "[mdx]": {
    "editor.wordWrap": "on"
  }
}