feat(vim): update selection mode to normal (while inclusive doesn't work) and add cut operations for word navigation
This commit is contained in:
parent
f9f57a6616
commit
87fb11eaa1
2 changed files with 42 additions and 18 deletions
|
@ -9,7 +9,7 @@
|
|||
"name": "NORMAL",
|
||||
"line_numbers": "relative",
|
||||
"cursor": "block",
|
||||
"selection": "inclusive",
|
||||
"selection": "normal",
|
||||
"press": [
|
||||
["b", "move_word_left_vim"],
|
||||
["w", "move_word_right_vim"],
|
||||
|
@ -32,15 +32,15 @@
|
|||
["O", ["smart_insert_line_before"], ["enter_mode", "insert"]],
|
||||
|
||||
["v", "enter_mode", "visual"],
|
||||
["V", ["move_begin"], ["enter_mode", "visual"], ["select_end"]],
|
||||
|
||||
["/", "find"],
|
||||
["n", "goto_next_match"],
|
||||
["0", "move_begin"],
|
||||
["^", "smart_move_begin"],
|
||||
["$", "move_end"],
|
||||
[":", "open_command_palette"],
|
||||
["p", "paste"],
|
||||
|
||||
["gd", "goto_definition"],
|
||||
["gi", "goto_implementation"],
|
||||
["gy", "goto_type_definition"],
|
||||
["gg", "move_buffer_begin"],
|
||||
|
@ -49,6 +49,8 @@
|
|||
["G", "move_buffer_end"],
|
||||
|
||||
["d$", "delete_to_end"],
|
||||
["dw", "cut_word_right_vim"],
|
||||
["db", "cut_word_left_vim"],
|
||||
["dd", "cut_internal"],
|
||||
["\"_dd", "delete_line"],
|
||||
|
||||
|
@ -62,10 +64,12 @@
|
|||
["<C-i>", "jump_forward"],
|
||||
["<C-y>", "redo"],
|
||||
|
||||
["/", "find"],
|
||||
|
||||
["<C-k>", "TODO"],
|
||||
|
||||
["<C-CR>", "smart_insert_line_after"],
|
||||
["<CR>", "smart_insert_line"]
|
||||
["<C-CR>", ["move_down"], ["move_begin"]],
|
||||
["<CR>", ["move_down"], ["move_begin"]]
|
||||
]
|
||||
},
|
||||
"visual": {
|
||||
|
@ -73,8 +77,8 @@
|
|||
"on_match_failure": "ignore",
|
||||
"name": "VISUAL",
|
||||
"line_numbers": "relative",
|
||||
"cursor": "underline",
|
||||
"selection": "inclusive",
|
||||
"cursor": "block",
|
||||
"selection": "normal",
|
||||
"press": [
|
||||
["<Esc>", "enter_mode", "normal"],
|
||||
["k", "select_up"],
|
||||
|
@ -97,7 +101,10 @@
|
|||
["<Esc>", "enter_mode", "normal"],
|
||||
["<Del>", "delete_forward"],
|
||||
["<BS>", "delete_backward"],
|
||||
["<CR>", "insert_line_after"]
|
||||
["<CR>", "smart_insert_line"],
|
||||
|
||||
["<C-BS>", "delete_word_left"],
|
||||
["<C-Del", "delete_word_right"]
|
||||
]
|
||||
},
|
||||
"home": {
|
||||
|
|
|
@ -2421,7 +2421,6 @@ pub const Editor = struct {
|
|||
var all_stop = true;
|
||||
var root = root_;
|
||||
|
||||
// For each cursor, collect what would be deleted
|
||||
var text = std.ArrayList(u8).init(self.allocator);
|
||||
var first = true;
|
||||
for (self.cursels.items) |*cursel_| if (cursel_.*) |*cursel| {
|
||||
|
@ -2587,14 +2586,6 @@ pub const Editor = struct {
|
|||
}
|
||||
pub const delete_forward_meta = .{ .description = "Delete next character" };
|
||||
|
||||
pub fn delete_backward(self: *Self, _: Context) Result {
|
||||
const b = try self.buf_for_update();
|
||||
const root = try self.delete_to(move_cursor_left, b.root, b.allocator);
|
||||
try self.update_buf(root);
|
||||
self.clamp();
|
||||
}
|
||||
pub const delete_backward_meta = .{ .description = "Delete previous character" };
|
||||
|
||||
pub fn cut_forward_internal(self: *Self, _: Context) Result {
|
||||
const b = try self.buf_for_update();
|
||||
const text, const root= try self.cut_to(move_cursor_right, b.root);
|
||||
|
@ -2602,7 +2593,15 @@ pub const Editor = struct {
|
|||
try self.update_buf(root);
|
||||
self.clamp();
|
||||
}
|
||||
pub const cut_forward_internal_meta = .{ .description = "Cut next character" };
|
||||
pub const cut_forward_internal_meta = .{ .description = "Cut next character to internal clipboard" };
|
||||
|
||||
pub fn delete_backward(self: *Self, _: Context) Result {
|
||||
const b = try self.buf_for_update();
|
||||
const root = try self.delete_to(move_cursor_left, b.root, b.allocator);
|
||||
try self.update_buf(root);
|
||||
self.clamp();
|
||||
}
|
||||
pub const delete_backward_meta = .{ .description = "Delete previous character" };
|
||||
|
||||
pub fn delete_word_left(self: *Self, _: Context) Result {
|
||||
const b = try self.buf_for_update();
|
||||
|
@ -2612,6 +2611,15 @@ pub const Editor = struct {
|
|||
}
|
||||
pub const delete_word_left_meta = .{ .description = "Delete previous word" };
|
||||
|
||||
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);
|
||||
self.set_clipboard_internal(text);
|
||||
try self.update_buf(root);
|
||||
self.clamp();
|
||||
}
|
||||
pub const cut_word_left_vim_meta = .{ .description = "Cut next character to internal clipboard" };
|
||||
|
||||
pub fn delete_word_right(self: *Self, _: Context) Result {
|
||||
const b = try self.buf_for_update();
|
||||
const root = try self.delete_to(move_cursor_word_right_space, b.root, b.allocator);
|
||||
|
@ -2620,6 +2628,15 @@ pub const Editor = struct {
|
|||
}
|
||||
pub const delete_word_right_meta = .{ .description = "Delete next word" };
|
||||
|
||||
pub fn cut_word_right_vim(self: *Self, _: Context) Result {
|
||||
const b = try self.buf_for_update();
|
||||
const text, const root= try self.cut_to(move_cursor_word_right_vim, b.root);
|
||||
self.set_clipboard_internal(text);
|
||||
try self.update_buf(root);
|
||||
self.clamp();
|
||||
}
|
||||
pub const cut_word_right_vim_meta = .{ .description = "Cut next character to internal clipboard" };
|
||||
|
||||
pub fn delete_to_begin(self: *Self, _: Context) Result {
|
||||
const b = try self.buf_for_update();
|
||||
const root = try self.delete_to(move_cursor_begin, b.root, b.allocator);
|
||||
|
|
Loading…
Add table
Reference in a new issue