Gatlin.io Icon
Image of Austin Gatlin's face
March 8, 2022

VSCode Vim Markdown Setup

I have been in the line-break/hard-wrap camp in the past, but now I'm in the word-wrap/soft-wrap camp. I want my markdown single-lined, word-wrapped at column 80, and I want to navigate through it with j, k, etc. I don't find myself line-jumping much in markdown, so I'm fine with the loss of 10j, for example. The keybindings code is mostly ripped from vscodevim faq plus the markdown lang check I added myself based on the vscode reference on when conditional clause operators. I don't remember how I learned about wordWrapColumn. Here are the settings:

// user settings file

{
  "[markdown]": {
    "editor.wordWrap": "wordWrapColumn",
    "editor.wordWrapColumn": 80
  }
}
// user keybindings file

[
  {
    "key": "up",
    "command": "cursorUp",
    "when": "editorLangId == markdown && editorTextFocus && vim.active && !inDebugRepl && !suggestWidgetMultipleSuggestions && !suggestWidgetVisible"
  },
  {
    "key": "down",
    "command": "cursorDown",
    "when": "editorLangId == markdown && editorTextFocus && vim.active && !inDebugRepl && !suggestWidgetMultipleSuggestions && !suggestWidgetVisible"
  },
  {
    "key": "k",
    "command": "cursorUp",
    "when": "editorLangId == markdown && editorTextFocus && vim.active && !inDebugRepl && vim.mode == 'Normal' && !suggestWidgetMultipleSuggestions && !suggestWidgetVisible"
  },
  {
    "key": "j",
    "command": "cursorDown",
    "when": "editorLangId == markdown && editorTextFocus && vim.active && !inDebugRepl && vim.mode == 'Normal' && !suggestWidgetMultipleSuggestions && !suggestWidgetVisible"
  }
]

If you are a hard-wrap enthusiast, theres a marketplace plugin called Rewrap that I've never used, but could be worth checking out.