|
| 1 | +# Vim Mode for TrustyNotes |
| 2 | + |
| 3 | +TrustyNotes includes a Vim-like editing mode that brings the power and efficiency of Vim keyboard shortcuts to the editor. This feature allows you to navigate and edit text using familiar Vim commands. |
| 4 | + |
| 5 | +## Enabling Vim Mode |
| 6 | + |
| 7 | +Vim mode can be toggled on/off using the "Vim Mode" switch in the editor toolbar. When enabled, you'll see a status indicator in the bottom right corner showing your current mode. |
| 8 | + |
| 9 | +## Modes |
| 10 | + |
| 11 | +Like Vim, this implementation has several editing modes: |
| 12 | + |
| 13 | +- **Normal Mode**: Default navigation and command mode (shown as "NORMAL") |
| 14 | +- **Insert Mode**: For typing and editing text (shown as "INSERT") |
| 15 | +- **Visual Mode**: For selecting text (shown as "VISUAL") |
| 16 | +- **Command Mode**: For executing commands (shown as "COMMAND") |
| 17 | + |
| 18 | +## Status Line |
| 19 | + |
| 20 | +When Vim mode is enabled, a status line appears at the bottom of the editor showing: |
| 21 | + |
| 22 | +- Current mode (NORMAL, INSERT, VISUAL, COMMAND) |
| 23 | +- Cursor position (line and column numbers) |
| 24 | +- Line Number |
| 25 | + |
| 26 | +## Command Reference |
| 27 | + |
| 28 | +### Mode Switching |
| 29 | + |
| 30 | +| Command | Description | |
| 31 | +|---------|-------------| |
| 32 | +| `Escape` | Switch to Normal mode from any other mode | |
| 33 | +| `i` | Enter Insert mode at cursor position | |
| 34 | +| `a` | Enter Insert mode after cursor position | |
| 35 | +| `o` | Open new line below cursor and enter Insert mode | |
| 36 | +| `O` | Open new line above cursor and enter Insert mode | |
| 37 | +| `v` | Enter Visual mode for character-wise selection | |
| 38 | +| `V` | Enter Visual line mode (select entire lines) | |
| 39 | +| `:` | Enter Command mode | |
| 40 | + |
| 41 | +### Navigation (Normal Mode) (Arrow Keys also work) |
| 42 | + |
| 43 | +| Command | Description | |
| 44 | +|---------|-------------| |
| 45 | +| `h` | Move cursor left | |
| 46 | +| `j` | Move cursor down | |
| 47 | +| `k` | Move cursor up | |
| 48 | +| `l` | Move cursor right | |
| 49 | +| `w` | Move to start of next word | |
| 50 | +| `b` | Move to start of previous word | |
| 51 | +| `e` | Move to end of current word | |
| 52 | +| `0` | Move to start of line | |
| 53 | +| `$` | Move to end of line | |
| 54 | +| `gg` | Move to beginning of document | |
| 55 | +| `G` | Move to end of document | |
| 56 | +| `{number}G` | Go to specific line number | |
| 57 | + |
| 58 | +### Editing (Normal Mode) |
| 59 | + |
| 60 | +| Command | Description | |
| 61 | +|---------|-------------| |
| 62 | +| `x` | Delete character under cursor | |
| 63 | +| `dd` | Delete current line | |
| 64 | +| `dw` | Delete word | |
| 65 | +| `d$` | Delete to end of line | |
| 66 | +| `cc` | Change entire line (delete and enter Insert mode) | |
| 67 | +| `cw` | Change word (delete word and enter Insert mode) | |
| 68 | +| `yy` | Yank (copy) current line | |
| 69 | +| `p` | Paste after cursor | |
| 70 | +| `P` | Paste before cursor | |
| 71 | +| `>>` | Indent line | |
| 72 | +| `<<` | Unindent line | |
| 73 | +| `u` | Undo | |
| 74 | +| `Ctrl+r` | Redo | |
| 75 | + |
| 76 | +### Search and Replace |
| 77 | + |
| 78 | +| Command | Description | |
| 79 | +|---------|-------------| |
| 80 | +| `/pattern` | Search forward for pattern | |
| 81 | +| `n` | Go to next search match | |
| 82 | +| `N` | Go to previous search match | |
| 83 | +| `:%s/pattern/replacement/g` | Global search and replace | |
| 84 | +| `:%s/pattern/replacement/gi` | Global search and replace (case insensitive) | |
| 85 | + |
| 86 | +## Examples |
| 87 | + |
| 88 | +### Basic Editing |
| 89 | + |
| 90 | +1. Press `i` to enter Insert mode and type text normally |
| 91 | +2. Press `Escape` to return to Normal mode |
| 92 | +3. Use `h`, `j`, `k`, `l` to navigate |
| 93 | +4. Press `dd` to delete a line |
| 94 | +5. Press `u` to undo changes |
| 95 | + |
| 96 | +### Search and Replace |
| 97 | + |
| 98 | +1. Press `:` to enter Command mode |
| 99 | +2. Type `%s/old text/new text/g` and press Enter |
| 100 | +3. All instances of "old text" will be replaced with "new text" |
| 101 | + |
| 102 | +### Efficient Navigation |
| 103 | + |
| 104 | +1. Press `gg` to go to the top of the document |
| 105 | +2. Press `G` to go to the bottom of the document |
| 106 | +3. Press `0` to go to the start of the current line |
| 107 | +4. Press `$` to go to the end of the current line |
| 108 | + |
| 109 | +## Tips |
| 110 | + |
| 111 | +- The status line at the bottom shows your current mode and cursor position |
| 112 | +- The status indicator in the bottom right corner always shows your current mode |
| 113 | +- You can combine commands with numbers (e.g., `5j` to move down 5 lines) |
| 114 | +- Press `Escape` anytime you're unsure, to return to Normal mode |
| 115 | +- When in Normal mode, all regular key presses are intercepted for commands |
| 116 | + |
| 117 | +## Keyboard Shortcuts Summary |
| 118 | + |
| 119 | +``` |
| 120 | +Navigation: h j k l w b e 0 $ gg G |
| 121 | +Insertion: i a o O |
| 122 | +Deletion: x dd dw d$ |
| 123 | +Change: cc cw |
| 124 | +Yank/Paste: yy p P |
| 125 | +Undo/Redo: u Ctrl+r |
| 126 | +Search: /pattern n N |
| 127 | +Search/Replace: :%s/pattern/replacement/g |
| 128 | +``` |
0 commit comments