Format Markdown on save in Zed using Prettier
20 Sept 24
One thing I’ve particularly enjoyed since switching to Zed is format-on-save, which is turned on by default in most programming modes. However, it’s not turned on by default for Markdown files.
Since I like my Markdown files formatted with Prettier,
including the “wrap to 80 cols” --prose-wrap always option, I set that command
as an “external” formatter for Markdown files and turned on format_on_save.
Here’s the config if you want to do the same:
"languages": {
"Markdown": {
"format_on_save": "on",
"formatter": {
"external": {
"command": "prettier",
"arguments": [
"--prose-wrap",
"always",
"--stdin-filepath",
"{buffer_path}"
]
}
}
}
} Cite this post
@online{swift2024formatMarkdownOnSaveInZedUsingPrettier,
author = {Ben Swift},
title = {Format Markdown on save in Zed using Prettier},
url = {https://benswift.me/blog/2024/09/20/format-markdown-on-save-in-zed-using-prettier/},
year = {2024},
month = {09},
note = {AT-URI: at://did:plc:tevykrhi4kibtsipzci76d76/site.standard.document/2024-09-20-format-markdown-on-save-in-zed-using-prettier},
}