This plugin trims trailing whitespace and lines.
Neovim v0.5.0+
Plug 'cappyzawa/trim.nvim'
-- default config
local config = {
disable = {},
patterns = {
[[%s/\s\+$//e]],
[[%s/\($\n\s*\)\+\%$//]],
[[%s/\%^\n\+//]],
[[%s/\(\n\n\)\n\+/\1/]],
},
}
lua <<EOF
require('trim').setup({
-- if you want to ignore markdown file.
-- you can specify filetypes.
disable = {"markdown"},
-- if you want to ignore space of top
patterns = {
[[%s/\s\+$//e]],
[[%s/\($\n\s*\)\+\%$//]],
[[%s/\(\n\n\)\n\+/\1/]],
},
})
EOF
If you save without formatting, use :noa w