Skip to content

feat(static-commands::delete_trailing_whitespace): wire trim_trailing_whitespace into command palette#15336

Open
doctorkotik187 wants to merge 5 commits intohelix-editor:masterfrom
doctorkotik187:feat/static-commands-delete-trailing-whitespace
Open

feat(static-commands::delete_trailing_whitespace): wire trim_trailing_whitespace into command palette#15336
doctorkotik187 wants to merge 5 commits intohelix-editor:masterfrom
doctorkotik187:feat/static-commands-delete-trailing-whitespace

Conversation

@doctorkotik187
Copy link
Copy Markdown
Contributor

Hi,

I suggest making trim_trailing_whitespace a la carte.

I do not see why this should not be the case, since all the infrastructure is already there.

I know there are a lot of ways to delete whitespace, and that you can set a config flag to delete it on :w.

But understand, sometimes I just fiddle with the file while thinking and it is nice to just type it in and know that the file is "clean" right now.

Like in vscode or emacs there is such a fn, I hope somebody can relate.


I ran cargo fmt --all and served with mdbook v0.4.52, all good.

Comment thread helix-term/src/commands/typed.rs Outdated
Comment on lines +425 to +429
// Wrapper for trim_trailing_whitespace().
pub fn delete_trailing_whitespace(cx: &mut Context) {
let (view, doc) = current!(cx.editor);
trim_trailing_whitespace(doc, view.id);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer trim_trailing_whitespace as the command name. The existing helper function can be renamed to trim_trailing_whitespace_impl or something similar.

@the-mikedavis
Copy link
Copy Markdown
Member

An alternative to a new static command for this would be to add a :trim-trailing-whitespace typable command. Typable commands are better for operations you don't expect to run very often, and they are also available in the command palette

@doctorkotik187
Copy link
Copy Markdown
Contributor Author

doctorkotik187 commented Apr 28, 2026

An alternative to a new static command for this would be to add a :trim-trailing-whitespace typable command. Typable commands are better for operations you don't expect to run very often, and they are also available in the command palette

Hello @the-mikedavis,

thanks for the reply, sorry I took quite a break from programming.

I tried it in commit 0068fb1, and it works, but I am not quite sure what I did, I just did the same thing the other TypableCommands did.

I don't know:

  • the placement of the command, I put it after the "format" one
  • what alias to pick or if we need one
  • if making a wrapper around the existing trim-trailing-whitespace fn was the correct move, I just did not want to change existing code

I also wanted to tell you, that I kinda don't need this feature heavily anymore, I just wanted to learn more about helix, when I've started it.

So if it is too much work, we can also let it go. But as for my part, I am still interested.

Can you tell me, I will fix if needed.

Thanks,
Emil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants