feat(vim): implement cut to end of line functionality in vim mode
This commit is contained in:
parent
b516709594
commit
0ea63accd9
2 changed files with 14 additions and 1 deletions
|
@ -62,7 +62,7 @@
|
||||||
["dd", "cut_internal_vim"],
|
["dd", "cut_internal_vim"],
|
||||||
["\"_dd", "delete_line"],
|
["\"_dd", "delete_line"],
|
||||||
|
|
||||||
["cc", ["delete_line"], ["enter_mode", "insert"]],
|
["cc", ["cut_internal_vim"], ["enter_mode", "insert"]],
|
||||||
["C", ["delete_to_end"], ["enter_mode", "insert"]],
|
["C", ["delete_to_end"], ["enter_mode", "insert"]],
|
||||||
["D", "delete_to_end"],
|
["D", "delete_to_end"],
|
||||||
["cw", ["cut_word_right_vim"], ["enter_mode", "insert"]],
|
["cw", ["cut_word_right_vim"], ["enter_mode", "insert"]],
|
||||||
|
|
|
@ -2088,6 +2088,10 @@ pub const Editor = struct {
|
||||||
cursor.move_end(root, metrics);
|
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 {
|
fn move_cursor_up(root: Buffer.Root, cursor: *Cursor, metrics: Buffer.Metrics) !void {
|
||||||
try cursor.move_up(root, metrics);
|
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 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 {
|
pub fn join_next_line(self: *Self, _: Context) Result {
|
||||||
const b = try self.buf_for_update();
|
const b = try self.buf_for_update();
|
||||||
try self.with_cursors_const(b.root, move_cursor_end);
|
try self.with_cursors_const(b.root, move_cursor_end);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue