Skip to content

Commit

Permalink
feat(commands): add clear_registers command
Browse files Browse the repository at this point in the history
  • Loading branch information
jorge committed Nov 26, 2022
1 parent 79ef39a commit 84489b6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
11 changes: 11 additions & 0 deletions book/src/keymap.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,17 @@ This layer is a kludge of mappings, mostly pickers.

> TIP: Global search displays results in a fuzzy picker, use `Space + '` to bring it back up after opening a file.
##### Register mode

Accessed by typing `'` in [normal mode](#normal-mode).

Works with registers.

| Key | Description | Command |
| ----- | ----------- | ------- |
| `"` | Select a register to yank to or paste from | `select_register` |
| `|` | Clear all registers | `clear_registers` |

##### Popup

Displays documentation for item under cursor.
Expand Down
4 changes: 4 additions & 0 deletions helix-core/src/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,8 @@ impl Registers {
pub fn inner(&self) -> &HashMap<char, Register> {
&self.inner
}

pub fn clear(&mut self) {
self.inner.clear();
}
}
7 changes: 7 additions & 0 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ impl MappableCommand {
wonly, "Close windows except current",
select_register, "Select register",
insert_register, "Insert register",
clear_registers, "Clear registers",
align_view_middle, "Align view middle",
align_view_top, "Align view top",
align_view_center, "Align view center",
Expand Down Expand Up @@ -4283,6 +4284,12 @@ fn insert_register(cx: &mut Context) {
})
}

fn clear_registers(cx: &mut Context) {
cx.editor.autoinfo = None;
cx.editor.registers.clear();
cx.editor.set_status("All registers cleared.")
}

fn align_view_top(cx: &mut Context) {
let (view, doc) = current!(cx.editor);
align_view(doc, view, Align::Top);
Expand Down
7 changes: 6 additions & 1 deletion helix-term/src/keymap/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,12 @@ pub fn default() -> HashMap<Mode, Keymap> {
"N" => search_prev,
},

"\"" => select_register,
"\'" => { "Registers"
"\"" => select_register,
"|" => clear_registers,
},

"\"" => select_register, // For backwards compatibility reasons
"|" => shell_pipe,
"A-|" => shell_pipe_to,
"!" => shell_insert_output,
Expand Down

0 comments on commit 84489b6

Please sign in to comment.