Compare commits

...

4 commits

Author SHA1 Message Date
ec783d68a6
feat: bind insert_command_name to ctrl+k ctrl+s in flow mode
Like in visual studio code, as insert_command_name is the closest thing
we have to a keybind reference.
2025-10-30 14:19:13 +01:00
eb11a40a9f
feat: bind select_line to alt+shift+e in flow mode
Like in visual studio, because the more common ctrl+l is already taken.

Also, remove some keybinds for commands that don't exist.
2025-10-30 14:18:17 +01:00
70a793d942
feat: add select_line command 2025-10-30 14:17:02 +01:00
21d1555aca
feat: add repeat argument to delete_line 2025-10-30 12:58:15 +01:00
2 changed files with 46 additions and 13 deletions

View file

@ -25,6 +25,7 @@
["alt+x", "open_command_palette"],
["f4", "toggle_input_mode"],
["ctrl+f2", "insert_command_name"],
["ctrl+k ctrl+s", "insert_command_name"],
["f9", "theme_prev"],
["f10", "theme_next"],
["f11", "toggle_panel"],
@ -168,8 +169,6 @@
["alt+}", "shrink_selection", true],
["alt+[", "select_prev_sibling", true],
["alt+]", "select_next_sibling", true],
["alt+shift+e", "move_parent_node_end"],
["alt+shift+b", "move_parent_node_start"],
["alt+a", "select_all_siblings"],
["alt+shift+home", "move_scroll_left"],
["alt+shift+end", "move_scroll_right"],
@ -202,6 +201,7 @@
["shift+enter", "smart_insert_line_before"],
["shift+backspace", "delete_backward"],
["ctrl+shift+k", "delete_line"],
["alt+shift+e", "select_line"],
["shift+tab", "unindent"],
["f2", "rename_symbol"],
["f3", "goto_next_match"],

View file

@ -3015,22 +3015,55 @@ pub const Editor = struct {
}
pub const delete_to_end_meta: Meta = .{ .description = "Delete to end of line" };
pub fn delete_line(self: *Self, _: Context) Result {
pub fn select_line(self: *Self, ctx: Context) Result {
const root = try self.buf_root();
var repeat: usize = 1;
_ = ctx.args.match(.{tp.extract(&repeat)}) catch false;
while (repeat > 0) : (repeat -= 1) {
for (self.cursels.items) |*cursel_| if (cursel_.*) |*cursel| {
if (cursel.selection) |*sel| {
sel.normalize();
move_cursor_begin(root, &sel.begin, self.metrics) catch {};
move_cursor_end(root, &sel.end, self.metrics) catch {};
blk: {
cursel.cursor.move_down(root, self.metrics) catch |e| switch (e) {
error.Stop => {
cursel.cursor.move_end(root, self.metrics);
break :blk;
},
};
move_cursor_begin(root, &cursel.cursor, self.metrics) catch {};
}
sel.end = cursel.cursor;
} else {
self.select_line_at_cursor(root, cursel, .include_eol) catch {};
}
};
self.collapse_cursors();
}
}
pub const select_line_meta: Meta = .{ .description = "Select current line", .arguments = &.{.integer} };
pub fn delete_line(self: *Self, ctx: Context) Result {
const b = try self.buf_for_update();
var root = b.root;
for (self.cursels.items) |*cursel_| if (cursel_.*) |*cursel| {
const col = cursel.cursor.col;
const target = cursel.cursor.target;
try self.select_line_at_cursor(root, cursel, .include_eol);
root = try self.delete_selection(root, cursel, b.allocator);
cursel.cursor.col = col;
cursel.cursor.target = target;
cursel.cursor.clamp_to_buffer(root, self.metrics);
};
var repeat: usize = 1;
_ = ctx.args.match(.{tp.extract(&repeat)}) catch false;
while (repeat > 0) : (repeat -= 1) {
for (self.cursels.items) |*cursel_| if (cursel_.*) |*cursel| {
const col = cursel.cursor.col;
const target = cursel.cursor.target;
try self.select_line_at_cursor(root, cursel, .include_eol);
root = try self.delete_selection(root, cursel, b.allocator);
cursel.cursor.col = col;
cursel.cursor.target = target;
cursel.cursor.clamp_to_buffer(root, self.metrics);
};
}
try self.update_buf(root);
self.clamp();
}
pub const delete_line_meta: Meta = .{ .description = "Delete current line" };
pub const delete_line_meta: Meta = .{ .description = "Delete current line", .arguments = &.{.integer} };
pub fn cut_to_end_vim(self: *Self, _: Context) Result {
const b = try self.buf_for_update();