fix: updated ctrl + home/end up/down behavior
5df1eccba968250a64b00c36935eff90705f1b88
Kevin Kortum <kevinkortum@me.com> · 2026-06-30 17:52
parent a38180c9
4 files changed
- → Remap-Home-End-to-doc-start-end-CtrlUp-Down-to-line-start-end.md +30 −0
@@ -0,0 +1,30 @@
+---
+id: TASK-033
+title: 'Remap Home/End to doc start/end, Ctrl+Up/Down to line start/end'
+status: "\U0001F3C1 Done"
+assignee: []
+created_date: '2026-07-01 00:32'
+updated_date: '2026-07-01 00:32'
+labels:
+ - bug
+dependencies: []
+modified_files:
+ - internal/editor/editor.go
+ - internal/help/help.go
+ - internal/editor/editor_test.go
+priority: medium
+ordinal: 32000
+---
+
+## Description
+
+<!-- SECTION:DESCRIPTION:BEGIN -->
+Home/End were overloaded with line-start/end (smart toggle) while doc-start/end lived on Ctrl+Home/Ctrl+End, leaving no clean way to reach the top/bottom of the doc without a modifier. Swapped: Home/End -> MoveDocStart/MoveDocEnd; Ctrl+Up/Ctrl+Down -> MoveHome/MoveEnd (line-level); Shift+Home/End and Ctrl+Shift+Up/Down updated to match for selection. Removed the now-redundant Ctrl+Home/Ctrl+End cases.
+<!-- SECTION:DESCRIPTION:END -->
+
+## Acceptance Criteria
+<!-- AC:BEGIN -->
+- [x] #1 Home/End jump to document start/end
+- [x] #2 Ctrl+Up/Ctrl+Down jump to line start (smart toggle) / line end
+- [x] #3 Shift variants extend selection consistently
+<!-- AC:END -->
internal/editor/editor.go +12 −6
@@ -700,16 +700,16 @@ return
}
e.ClearSelection()
e.MoveDown()
- case tea.KeyHome:
+ case tea.KeyCtrlUp:
e.ClearSelection()
e.MoveHome()
- case tea.KeyEnd:
+ case tea.KeyCtrlDown:
e.ClearSelection()
e.MoveEnd()
- case tea.KeyCtrlHome:
+ case tea.KeyHome:
e.ClearSelection()
e.MoveDocStart()
- case tea.KeyCtrlEnd:
+ case tea.KeyEnd:
e.ClearSelection()
e.MoveDocEnd()
@@ -728,16 +728,22 @@ e.startSelection()
e.MoveDown()
case tea.KeyShiftHome:
e.startSelection()
- e.MoveHome()
+ e.MoveDocStart()
case tea.KeyShiftEnd:
e.startSelection()
- e.MoveEnd()
+ e.MoveDocEnd()
case tea.KeyCtrlShiftLeft:
e.startSelection()
e.MoveWordLeft()
case tea.KeyCtrlShiftRight:
e.startSelection()
e.MoveWordRight()
+ case tea.KeyCtrlShiftUp:
+ e.startSelection()
+ e.MoveHome()
+ case tea.KeyCtrlShiftDown:
+ e.startSelection()
+ e.MoveEnd()
}
}
internal/editor/editor_test.go +21 −4
@@ -416,13 +416,30 @@
func TestDocStartEnd(t *testing.T) {
e := newEditorWith("first", "middle", "last line")
e.Cursor = Position{Row: 1, Col: 2}
- e.HandleKey(tea.KeyMsg{Type: tea.KeyCtrlEnd})
+ e.HandleKey(tea.KeyMsg{Type: tea.KeyEnd})
if e.Cursor != (Position{Row: 2, Col: 9}) {
- t.Errorf("Ctrl+End → %+v, want {2 9}", e.Cursor)
+ t.Errorf("End → %+v, want {2 9}", e.Cursor)
}
- e.HandleKey(tea.KeyMsg{Type: tea.KeyCtrlHome})
+ e.HandleKey(tea.KeyMsg{Type: tea.KeyHome})
if e.Cursor != (Position{Row: 0, Col: 0}) {
- t.Errorf("Ctrl+Home → %+v, want {0 0}", e.Cursor)
+ t.Errorf("Home → %+v, want {0 0}", e.Cursor)
+ }
+}
+
+func TestLineStartEndViaCtrlUpDown(t *testing.T) {
+ e := newEditorWith(" indented line")
+ e.Cursor = Position{Row: 0, Col: 8}
+ e.HandleKey(tea.KeyMsg{Type: tea.KeyCtrlDown})
+ if e.Cursor.Col != len(" indented line") {
+ t.Errorf("Ctrl+Down → col %d, want %d (line end)", e.Cursor.Col, len(" indented line"))
+ }
+ e.HandleKey(tea.KeyMsg{Type: tea.KeyCtrlUp})
+ if e.Cursor.Col != 2 {
+ t.Errorf("Ctrl+Up → col %d, want 2 (first non-blank)", e.Cursor.Col)
+ }
+ e.HandleKey(tea.KeyMsg{Type: tea.KeyCtrlUp})
+ if e.Cursor.Col != 0 {
+ t.Errorf("Ctrl+Up again → col %d, want 0 (toggle to column 0)", e.Cursor.Col)
}
}
internal/help/help.go +2 −1
@@ -41,6 +41,8 @@ Ctrl+F fuzzy file picker (prefix the query with / to full-text
search note contents; results open at the matching line)
Ctrl+G find in document (Enter/down next, Shift+Tab/up prev)
Ctrl+L go to line (type a number, Enter to jump)
+ Home / End top / bottom of the document
+ Ctrl+Up / Ctrl+Down line start (first non-blank, then column 0) / line end
Ctrl+D today's daily note
Ctrl+N new note in the current directory
Ctrl+B new note in the inbox
@@ -59,7 +61,6 @@ Ctrl+Q quit (press twice if there are unsaved changes)
Esc back to the editor
EDITING
- Home jump to the first non-blank column, then to column 0
( [ and backtick auto-close (no selection): inserts the matching closer
with the cursor between; type the closer to step past
paste a URL on a selection wraps it as a [selection](url) link