diff --git a/src/keybind/builtin/helix.json b/src/keybind/builtin/helix.json index 5de4845..1225b17 100644 --- a/src/keybind/builtin/helix.json +++ b/src/keybind/builtin/helix.json @@ -120,7 +120,7 @@ ["v", "enter_mode", "select"], - ["g g", "move_buffer_begin"], + ["g g", "goto_line_vim"], ["g e", "move_buffer_end"], ["g f", "goto_file"], ["g h", "move_begin"], diff --git a/src/keybind/builtin/vim.json b/src/keybind/builtin/vim.json index 1733265..21aa567 100644 --- a/src/keybind/builtin/vim.json +++ b/src/keybind/builtin/vim.json @@ -51,7 +51,7 @@ ["gd", "goto_definition"], ["gi", "goto_implementation"], ["gy", "goto_type_definition"], - ["gg", "move_buffer_begin"], + ["gg", "goto_line_vim"], ["grn", "rename_symbol"], ["gD", "goto_declaration"], ["G", "move_buffer_end"], diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 41e21be..06564af 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -5057,6 +5057,18 @@ pub const Editor = struct { } pub const goto_line_meta: Meta = .{ .arguments = &.{.integer} }; + pub fn goto_line_vim(self: *Self, ctx: Context) Result { + try self.send_editor_jump_source(); + var line: usize = 0; + _ = ctx.args.match(.{tp.extract(&line)}) catch false; + const root = self.buf_root() catch return; + const primary = self.get_primary(); + try primary.cursor.move_to(root, @intCast(if (line < 1) 0 else line - 1), primary.cursor.col, self.metrics); + self.clamp(); + try self.send_editor_jump_destination(); + } + pub const goto_line_vim_meta: Meta = .{ .arguments = &.{.integer} }; + pub fn goto_column(self: *Self, ctx: Context) Result { var column: usize = 0; if (!try ctx.args.match(.{tp.extract(&column)}))