diff --git a/src/keybind/builtin/vim.json b/src/keybind/builtin/vim.json index 458a6a6..54c1a0e 100644 --- a/src/keybind/builtin/vim.json +++ b/src/keybind/builtin/vim.json @@ -62,7 +62,7 @@ ["dd", "cut_internal_vim"], ["\"_dd", "delete_line"], - ["cc", ["delete_line"], ["enter_mode", "insert"]], + ["cc", ["cut_internal_vim"], ["enter_mode", "insert"]], ["C", ["delete_to_end"], ["enter_mode", "insert"]], ["D", "delete_to_end"], ["cw", ["cut_word_right_vim"], ["enter_mode", "insert"]], diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 02db304..4f42bd2 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -2088,6 +2088,10 @@ pub const Editor = struct { cursor.move_end(root, metrics); } + fn move_cursor_end_vim(root: Buffer.Root, cursor: *Cursor, metrics: Buffer.Metrics) !void { + move_cursor_right_until(root, cursor, is_eol_vim, metrics); + } + fn move_cursor_up(root: Buffer.Root, cursor: *Cursor, metrics: Buffer.Metrics) !void { try cursor.move_up(root, metrics); } @@ -2776,6 +2780,15 @@ pub const Editor = struct { } pub const delete_to_end_meta = .{ .description = "Delete to end of line" }; + pub fn cut_to_end_vim(self: *Self, _: Context) Result { + const b = try self.buf_for_update(); + const text, const root = try self.cut_to(move_cursor_end_vim, b.root); + self.set_clipboard_internal(text); + try self.update_buf(root); + self.clamp(); + } + pub const cut_to_end_vim_meta = .{ .description = "Cut to end of line (vim)" }; + pub fn join_next_line(self: *Self, _: Context) Result { const b = try self.buf_for_update(); try self.with_cursors_const(b.root, move_cursor_end);