Claude Code /vim: Use hjkl in Your AI Terminal
Table of Contents
- What Is /vim
- How to Use It
- Two Modes
- INSERT Mode
- NORMAL Mode
- Supported Vim Keybindings
- Movement
- Find
- Operators
- Line Operations
- Character Operations
- Text Objects
- Mode Switching
- Other
- Unsupported Vim Features
- Scope
- Practical Tips
- Tip 1: Vim Shines with Multi-Line Input
- Tip 2: Dot-Repeat Is the Killer Feature
- Tip 3: Text Objects for Quotes and Brackets
- Tip 4: Count Prefix for Bulk Operations
- Tip 5: Turn It Off Anytime
- Final Thoughts
What Is /vim
If you’re a Vim user, your fingers have already built muscle memory — hjkl to move the cursor, dd to delete a line, ciw to replace a word, Esc to return to NORMAL mode.
In Claude Code’s input box, the default is standard readline keybindings. Every time you want to move the cursor, you reach for the arrow keys. Deleting a word means hitting backspace repeatedly — for Vim users, this is painful.
/vim turns Claude Code’s input box into a mini Vim editor. Type normally in INSERT mode, press Esc to switch to NORMAL mode and use Vim keybindings to manipulate text.
How to Use It
/vim
A simple toggle. Type it once to enable Vim mode, type it again to disable.
When enabled, you’ll see:
Editor mode set to vim. Use Escape key to toggle between INSERT and NORMAL modes.
This setting is global and persists in your config — Vim mode remains active the next time you start Claude Code.
Two Modes
INSERT Mode
- Works just like normal input — typing goes directly into the text box
- Bottom-left of the input box shows
-- INSERT -- - Press Esc to switch to NORMAL mode
NORMAL Mode
- Keystrokes don’t enter text — they execute Vim commands
- The
-- INSERT --indicator disappears - Press i / a / o to return to INSERT mode
- Press Enter to send the current content (same as normal mode)
It starts in INSERT mode by default, so you can start typing immediately.
Supported Vim Keybindings
Movement
| Key | Action |
|---|---|
h / l | Move left / right one character |
j / k | Move down / up one line (logical) |
gj / gk | Move down / up one line (display) |
w / b | Next / previous word start |
e | End of current word |
W / B / E | Same but whitespace-delimited (WORD) |
0 | Start of line |
^ | First non-blank character of line |
$ | End of line |
gg | Start of text (or line N) |
G | End of text (or line N) |
| Arrow keys | Mapped to hjkl in NORMAL mode |
Find
| Key | Action |
|---|---|
f{char} | Find char forward (cursor on char) |
F{char} | Find char backward |
t{char} | Find char forward (cursor before char) |
T{char} | Find char backward (cursor after char) |
; | Repeat last find |
, | Repeat last find (reversed) |
Operators
Operators compose with motions, text objects, and count prefixes — this is Vim’s “grammar”:
| Key | Action |
|---|---|
d | Delete |
c | Change (delete + enter INSERT) |
y | Yank (copy) |
Composition examples:
dw— delete to next wordd2w— delete to the 2nd word aheadc$— change from cursor to end of lineyy— yank entire line3dd— delete 3 lines
Line Operations
| Key | Action |
|---|---|
dd | Delete entire line |
cc | Change entire line |
yy | Yank entire line |
D | Delete to end of line (= d$) |
C | Change to end of line (= c$) |
Y | Yank entire line |
>> | Indent (2 spaces) |
<< | Dedent |
J | Join lines |
Character Operations
| Key | Action |
|---|---|
x | Delete character under cursor |
r{char} | Replace character under cursor |
~ | Toggle case |
Text Objects
Text objects are used after an operator. i means “inner”, a means “including boundaries”:
| Key | Scope |
|---|---|
iw / aw | Word |
iW / aW | WORD (whitespace-delimited) |
i" / a" | Inside double quotes |
i' / a' | Inside single quotes |
i` / a` | Inside backticks |
i( / a( | Inside parentheses |
i[ / a[ | Inside square brackets |
i{ / a{ | Inside curly braces |
i< / a< | Inside angle brackets |
Composition examples:
ciw— change entire worddi"— delete contents inside double quotesda(— delete parentheses and their contentsyi{— yank contents inside curly braces
Mode Switching
| Key | Action |
|---|---|
i | Insert before cursor |
I | Insert at first non-blank of line |
a | Insert after cursor |
A | Insert at end of line |
o | Open line below + INSERT |
O | Open line above + INSERT |
Esc | Return to NORMAL mode |
Other
| Key | Action |
|---|---|
p | Paste after (linewise-aware) |
P | Paste before |
. | Dot-repeat last change |
u | Undo |
? | Help shortcut (in NORMAL idle) |
1-9 | Count prefix, repeat following action |
Unsupported Vim Features
To keep things practical for a terminal input box, these Vim features are not implemented:
/and?search (limited value in an input box)- Visual mode (
v/V/ Ctrl-V) - Macro recording (
q) - Marks (
m) - Named registers (
") - Ex commands (
:) %bracket matching*/#word search- Ctrl-R redo
- Ctrl-U / Ctrl-D half-page scroll
These are useful in a full Vim editor but aren’t essential in Claude Code’s input box context.
Scope
Vim mode only affects the input box. Specifically:
- Claude’s response output, tool call results, conversation history display, and all other UI elements are completely unaffected
- You cannot use Vim keybindings to scroll through conversation history or select output text
- Ctrl combinations (Ctrl+C, Ctrl+D, etc.) work normally in both modes
- Enter in NORMAL mode still sends the message
Practical Tips
Tip 1: Vim Shines with Multi-Line Input
When you need to type a longer prompt, especially multi-line content, Vim mode really shines. o to open a new line, dd to remove an unwanted line, ciw to quickly replace a word — much more efficient than arrow keys and backspace.
Tip 2: Dot-Repeat Is the Killer Feature
The . key repeats the last change operation. For example, use ciw to change a variable name, move to the next occurrence and press . to instantly perform the same replacement. Incredibly useful when writing complex prompts.
Tip 3: Text Objects for Quotes and Brackets
When writing prompts, you often need to modify content inside quotes or brackets. ci" to clear double-quoted content and enter INSERT mode, da( to delete parentheses and their contents — these text object operations are especially handy when editing JSON examples or code snippets.
Tip 4: Count Prefix for Bulk Operations
3dd to delete 3 lines, 5j to move down 5 lines — count prefixes let you skip step-by-step operations and jump straight to your target. The count limit is 10000, so no worries about accidentally freezing with a huge number.
Tip 5: Turn It Off Anytime
If you find Vim mode isn’t for you, or want to switch back to normal mode in certain situations, just type /vim again to disable it. The setting persists, but toggling is instant.
Final Thoughts
/vim isn’t a “feature” — it’s a form of respect. Respect for the editing habits you’ve built over the years.
For non-Vim users, this command may hold zero appeal. But for Vim users, being able to use familiar hjkl, ciw, dd, . to edit prompts in Claude Code feels as natural as being in your own editor.
Muscle memory doesn’t need retraining. Tools should adapt to you, not the other way around.
Related Articles
Claude Code Agent Loop: Dissecting the Heart of an AI Coding Assistant
How does Claude Code understand your requests, invoke tools, and self-recover step by step? A source-code deep dive into the Agent Loop's core architecture — streaming responses, parallel tool execution, auto-compaction, and error recovery.
Claude Code settings.json Explained (1): Where Config Files Live and Who Wins
A complete guide to Claude Code's configuration file system — five config sources, their file paths, priority rules, array merging vs value overriding, and enterprise managed settings delivery.
Claude Code settings.json Deep Dive (Part 2): The Permissions System
A thorough breakdown of Claude Code's permissions configuration — allow/deny/ask rule arrays, wildcard syntax, MCP tool permissions, defaultMode options, and additionalDirectories.
Claude Code settings.json Deep Dive (Part 3): The Hooks System
A thorough breakdown of Claude Code's hooks configuration — four hook types, core events (PreToolUse/PostToolUse/Stop/Notification), stdin/stdout protocol, exit code semantics, and practical examples.
Claude Code settings.json Deep Dive (4): env, Models, Auth, and Other Useful Fields
A comprehensive guide to the remaining settings.json fields in Claude Code — env variable injection, model configuration, authentication helpers, Git attribution, session cleanup, language and UI, thinking depth, auto-updates, memory system, and more.