cappyzawa/trim.nvim

Compare with replace

Closed this issue · 3 comments

HI!
I'm searching for the best way to trim trailing whitespaces and your plugin looks really good.

Why did you decide to write your own trim function instead of using replace command :%s/\s\+$//e (more details)?

Hi.

Why did you decide to write your own trim function instead of using replace command :%s/\s\+$//e (more details)?

This command can trim trailing whitespace, but it cannot trim trailing lines.

If you have a file like the following, the end of the line will not be trimmed.

foo
baa

Thank you for the explanation.

I found how to trim last empty lines in file: :%s#\($\n\s*\)\+\%$## (here).

It would be interesting to compare what is faster: your implementation or two regexps.

Thanks for your information 👍

There were some problems with my implementation, so I will adopt the method you taught me.