From 28fdd957479a669e80771485053670d7fac410a6 Mon Sep 17 00:00:00 2001 From: Robert Burnett Date: Sun, 11 May 2025 20:44:09 -0500 Subject: [PATCH] added cut_buffer_begin command and vim binding --- src/keybind/builtin/vim.json | 1 + src/tui/editor.zig | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/keybind/builtin/vim.json b/src/keybind/builtin/vim.json index fc4bd7f..9f7e2e0 100644 --- a/src/keybind/builtin/vim.json +++ b/src/keybind/builtin/vim.json @@ -61,6 +61,7 @@ ["db", "cut_word_left_vim"], ["dd", "cut_internal_vim"], ["dG", "cut_buffer_end"], + ["dgg", "cut_buffer_begin"], ["\"_dd", "delete_line"], ["cc", ["enter_mode", "insert"], ["cut_internal_vim"]], diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 51a492f..2509bad 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -2970,6 +2970,15 @@ pub const Editor = struct { } pub const cut_buffer_end_meta: Meta = .{ .description = "Cut to the end of the buffer (copies cut text into clipboard)" }; + pub fn cut_buffer_begin(self: *Self, _: Context) Result { + const b = try self.buf_for_update(); + const text, const root = try self.cut_to(move_cursor_buffer_begin, b.root); + self.set_clipboard_internal(text); + try self.update_buf(root); + self.clamp(); + } + pub const cut_buffer_begin_meta: Meta = .{ .description = "Cut to the beginning of the buffer (copies cut text into clipboard)" }; + pub fn cut_word_left_vim(self: *Self, _: Context) Result { const b = try self.buf_for_update(); const text, const root = try self.cut_to(move_cursor_word_left_vim, b.root);