Skip to content

Commit 3fc62df

Browse files
author
Matthias Bidlingmeyer
committed
feat: add vim insert at start of line action to query editor
1 parent c2a82b5 commit 3fc62df

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

sqlit/core/keymap.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ def _build_action_keys(self) -> list[ActionKeyDef]:
329329
ActionKeyDef("question_mark", "show_help", "global"),
330330
# Query (normal mode)
331331
ActionKeyDef("i", "enter_insert_mode", "query_normal"),
332+
ActionKeyDef("I", "prepend_insert_mode", "query_normal"),
332333
ActionKeyDef("o", "open_line_below", "query_normal"),
333334
ActionKeyDef("O", "open_line_above", "query_normal"),
334335
ActionKeyDef("enter", "execute_query", "query_normal"),

sqlit/domains/query/state/query_normal.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def _setup_actions(self) -> None:
3838
self.allows("cursor_find_char_back", help="Find char backward")
3939
self.allows("cursor_till_char", help="Move till char forward")
4040
self.allows("cursor_till_char_back", help="Move till char backward")
41+
self.allows("prepend_insert_mode", help="Insert at line start")
4142
self.allows("append_insert_mode", help="Append after cursor")
4243
self.allows("append_line_end", help="Append at line end")
4344
# Vim open line

sqlit/domains/query/ui/mixins/query_editing_cursor.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ def action_cursor_till_char_back(self: QueryMixinHost) -> None:
118118
"""Move till after previous char (T{c})."""
119119
self._show_motion_char_pending_menu("T")
120120

121+
def action_prepend_insert_mode(self: QueryMixinHost) -> None:
122+
"""Enter insert mode at start of line (I)."""
123+
row, _ = self.query_input.cursor_location
124+
self.query_input.cursor_location = (row, 0)
125+
self.action_enter_insert_mode()
126+
121127
def action_append_insert_mode(self: QueryMixinHost) -> None:
122128
"""Enter insert mode after cursor (a)."""
123129
lines = self.query_input.text.split("\n")

sqlit/domains/shell/state/machine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def binding(key: str, desc: str, indent: int = 4) -> str:
185185
# ═══════════════════════════════════════════════════════════════════
186186
lines.append(section("QUERY EDITOR"))
187187
lines.append(subsection("Normal Mode:"))
188-
lines.append(binding("i", "Enter INSERT mode"))
188+
lines.append(binding("i/I", "Enter INSERT mode"))
189189
lines.append(binding("o/O", "Open line below/above"))
190190
lines.append(binding("C", "Change to line end"))
191191
lines.append(binding("D", "Delete to line end"))

0 commit comments

Comments
 (0)