Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions book/src/generated/static-cmd.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
| `goto_previous_buffer` | Goto previous buffer | normal: `` gp ``, select: `` gp `` |
| `goto_line_end_newline` | Goto newline at line end | insert: `` <end> `` |
| `goto_first_nonwhitespace` | Goto first non-blank in line | normal: `` gs ``, select: `` gs `` |
| `delete_trailing_whitespace` | Delete trailing whitespace in document | |
| `trim_selections` | Trim whitespace from selections | normal: `` _ ``, select: `` _ `` |
| `extend_to_line_start` | Extend to line start | select: `` <home> `` |
| `extend_to_first_nonwhitespace` | Extend to first non-blank in line | |
Expand Down
1 change: 1 addition & 0 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ impl MappableCommand {
goto_previous_buffer, "Goto previous buffer",
goto_line_end_newline, "Goto newline at line end",
goto_first_nonwhitespace, "Goto first non-blank in line",
delete_trailing_whitespace, "Delete trailing whitespace in document",
trim_selections, "Trim whitespace from selections",
extend_to_line_start, "Extend to line start",
extend_to_first_nonwhitespace, "Extend to first non-blank in line",
Expand Down
6 changes: 6 additions & 0 deletions helix-term/src/commands/typed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,12 @@ fn write_impl(
Ok(())
}

// 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.


/// Trim all whitespace preceding line-endings in a document.
fn trim_trailing_whitespace(doc: &mut Document, view_id: ViewId) {
let text = doc.text();
Expand Down