Skip to content

Add Vim keybindings mode for SQL editor#28

Open
muk2 wants to merge 2 commits intomainfrom
feature/issue-17-vim-keybindings
Open

Add Vim keybindings mode for SQL editor#28
muk2 wants to merge 2 commits intomainfrom
feature/issue-17-vim-keybindings

Conversation

@muk2
Copy link
Owner

@muk2 muk2 commented Feb 18, 2026

Summary

Implements Issue #17 — an optional Vim-style editing mode for the SQL editor.

  • Ctrl+Shift+V toggles between Vim and standard editing mode
  • Preference persisted to ~/.config/pgrsql/vim_mode
  • Mode indicator shown in status bar (NORMAL/INSERT/VISUAL/V-LINE)

Normal Mode

Key Action
h/j/k/l Move left/down/up/right
w/b/e Word forward/backward/end
0/$/^ Line start/end/first non-whitespace
gg/G Go to first/last line
i/a/I/A Enter Insert mode (at cursor/after/line start/line end)
o/O New line below/above, enter Insert
v/V Enter Visual/Visual-Line mode
x Delete character
dd/dw/d$/d0 Delete line/word/to-end/to-start
yy/yw/y$ Yank line/word/to-end
cc/cw/c$ Change line/word/to-end
p/P Paste after/before cursor
Count prefix (e.g., 3j) Repeat motion N times

Insert Mode

  • Standard editing keybindings
  • Esc returns to Normal mode

Visual/V-Line Mode

  • Motions extend selection
  • d/y/c operate on selection

Changes

File Changes
src/ui/app.rs Added VimMode enum, vim state fields, handle_vim_normal_input(), handle_vim_insert_input(), handle_vim_visual_input(), vim helpers, toggle keybinding, preference persistence
src/ui/components.rs Added vim mode indicator in status bar, updated help overlay

Test plan

  • All 124 existing tests pass
  • cargo clippy clean
  • cargo fmt clean
  • Manual test: Ctrl+Shift+V enables vim mode, status bar shows "NORMAL"
  • Manual test: i enters insert mode, Esc returns to normal
  • Manual test: h/j/k/l navigate, w/b word motions work
  • Manual test: dd deletes line, yy yanks, p pastes
  • Manual test: v enters visual mode, d deletes selection
  • Manual test: Ctrl+Enter/F5 executes query in all modes
  • Manual test: Ctrl+Shift+V disables vim mode

🤖 Generated with Claude Code

muk2 and others added 2 commits February 18, 2026 22:59
Implements an optional Vim-style editing mode toggled with Ctrl+Shift+V.
Supports Normal mode (h/j/k/l motions, w/b/e word motions, 0/$/^/G/gg
jumps, d/y/c operators with motions, x delete, p/P paste, i/a/I/A/o/O
insert transitions), Insert mode (standard editing with Esc to return),
and Visual/Visual-Line mode (extend selection with motions, d/y/c to act).
Shows mode indicator in status bar. Preference persisted to config file.

Closes #17

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Ctrl+Shift+V was intercepted by most terminals as paste before
crossterm could see it. Fix the toggle to support three methods:

- Ctrl+Shift+V: now matches uppercase 'V' with CONTROL only (shift
  is implicit in the uppercase letter), works in terminals that don't
  intercept this combo
- Alt+V: universal alternative that works on all terminals
- F2: function key fallback, never intercepted by terminals

Update help overlay and add vim mode documentation to README.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant