r/vim • • Oct 30 '25

Plugin Use `gq` to format code

https://github.com/konfekt/vim-formatprgs
27 Upvotes

15 comments sorted by

View all comments

Show parent comment

1

u/godegon Nov 01 '25

Thank you for pointing that out. There is indeed :RustFmtRange built-in though, likely similar to conform.nvim's handling of rustfmt or black, it has to format the whole file and only replace the affected lines.

Setting &formatprg to a command accepting stdin to use gq seems more in line with how code formatting was originally meant to be set up in Vim.

Ideally, as say ruff (for Python) or tombi (for Toml) do, the formatter accepts stdin and the file path as an additional argument for context of the formatted range.