From ea407ccdba139605fbcc19ea058f68a10a9cfb86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Mon, 29 Mar 2021 15:29:03 +0900 Subject: [PATCH] Implement g as goto line n. --- helix-term/src/commands.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 0745c624e..ecafaa1da 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1032,6 +1032,16 @@ pub fn normal_mode(cx: &mut Context) { } pub fn goto_mode(cx: &mut Context) { + let count = cx.count; + if count > 1 { + // TODO: can't go to line 1 since we can't distinguish between g and 1g, g gets converted + // to 1g + let doc = cx.doc(); + let pos = doc.text().line_to_char(count - 1); + doc.set_selection(Selection::point(pos)); + return; + } + cx.on_next_key(move |cx, event| { if let KeyEvent { code: KeyCode::Char(ch),