Editing Markdown in Zed

I’ve been cheating on Neovim lately. I’m playing around with Zed (in vim mode, naturally). Zed’s default settings allow Markdown editing just fine, of course. Markdown is just text, after all. I don’t want long lines to scroll off the right side of the screen, though. Horizontal scrolling is the worst. I want lines to wrap when they get to the right margin. To enable soft wrapping (and to enable vim mode), open Zed’s settings file ($XDG_CONFIG_HOME/zed/settings.json) and add these lines:

{
  "vim_mode": true,
  "soft_wrap": "editor_width"
}

While this improves the Markdown-editing experience, the vim up-down motion commands, j and k, ignore the wrapping and move up or down a complete line — which makes them move up or down an entire paragraph. I want them to move up or down a visual line, so I added these lines to the keymap settings file ($XDG_CONFIG_HOME/zed/keymap.json):

[
  {
    "context": "Editor && vim_mode == normal",
    "bindings": {
      "j": ["workspace::SendKeystrokes", "g j"],
      "k": ["workspace::SendKeystrokes", "g k"]
    }
  }
]

gj and gk correspond to “display lines downward/upward” and are not linewise, so when soft wrap is on, they move count display lines, not physical lines.

A much better experience than the defaults when editing Markdown!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.