diff --git a/data/core/commands/doc.lua b/data/core/commands/doc.lua index 60a913ce..95919a70 100644 --- a/data/core/commands/doc.lua +++ b/data/core/commands/doc.lua @@ -418,6 +418,7 @@ local translations = { ["start-of-line"] = translate.start_of_line, ["end-of-line"] = translate.end_of_line, ["start-of-word"] = translate.start_of_word, + ["start-of-indentation"] = translate.start_of_indentation, ["end-of-word"] = translate.end_of_word, ["previous-line"] = DocView.translate.previous_line, ["next-line"] = DocView.translate.next_line, diff --git a/data/core/doc/translate.lua b/data/core/doc/translate.lua index b084e89a..d1bde5f0 100644 --- a/data/core/doc/translate.lua +++ b/data/core/doc/translate.lua @@ -117,6 +117,10 @@ function translate.start_of_line(doc, line, col) return line, 1 end +function translate.start_of_indentation(doc, line, col) + local s, e = doc.lines[line]:find("^%s*") + return line, col > e + 1 and e + 1 or 1 +end function translate.end_of_line(doc, line, col) return line, math.huge diff --git a/data/core/keymap-macos.lua b/data/core/keymap-macos.lua index e233bb2e..647cb132 100644 --- a/data/core/keymap-macos.lua +++ b/data/core/keymap-macos.lua @@ -80,7 +80,7 @@ local function keymap_macos(keymap) ["cmd+right"] = "doc:move-to-next-word-end", ["cmd+["] = "doc:move-to-previous-block-start", ["cmd+]"] = "doc:move-to-next-block-end", - ["home"] = "doc:move-to-start-of-line", + ["home"] = "doc:move-to-start-of-indentation", ["end"] = "doc:move-to-end-of-line", ["cmd+home"] = "doc:move-to-start-of-doc", ["cmd+end"] = "doc:move-to-end-of-doc", @@ -95,7 +95,7 @@ local function keymap_macos(keymap) ["cmd+shift+right"] = "doc:select-to-next-word-end", ["cmd+shift+["] = "doc:select-to-previous-block-start", ["cmd+shift+]"] = "doc:select-to-next-block-end", - ["shift+home"] = "doc:select-to-start-of-line", + ["shift+home"] = "doc:select-to-start-of-indentation", ["shift+end"] = "doc:select-to-end-of-line", ["cmd+shift+home"] = "doc:select-to-start-of-doc", ["cmd+shift+end"] = "doc:select-to-end-of-doc", diff --git a/data/core/keymap.lua b/data/core/keymap.lua index 86be82b1..93ca39a3 100644 --- a/data/core/keymap.lua +++ b/data/core/keymap.lua @@ -184,7 +184,7 @@ keymap.add_direct { ["ctrl+right"] = "doc:move-to-next-word-end", ["ctrl+["] = "doc:move-to-previous-block-start", ["ctrl+]"] = "doc:move-to-next-block-end", - ["home"] = "doc:move-to-start-of-line", + ["home"] = "doc:move-to-start-of-indentation", ["end"] = "doc:move-to-end-of-line", ["ctrl+home"] = "doc:move-to-start-of-doc", ["ctrl+end"] = "doc:move-to-end-of-doc", @@ -199,7 +199,7 @@ keymap.add_direct { ["ctrl+shift+right"] = "doc:select-to-next-word-end", ["ctrl+shift+["] = "doc:select-to-previous-block-start", ["ctrl+shift+]"] = "doc:select-to-next-block-end", - ["shift+home"] = "doc:select-to-start-of-line", + ["shift+home"] = "doc:select-to-start-of-indentation", ["shift+end"] = "doc:select-to-end-of-line", ["ctrl+shift+home"] = "doc:select-to-start-of-doc", ["ctrl+shift+end"] = "doc:select-to-end-of-doc",