Logo Vincent
Back to all posts

Claude Code /vim: Vim Keybindings in Your AI Coding Assistant

Claude
Claude Code /vim: Vim Keybindings in Your AI Coding Assistant

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

KeyAction
h / lMove left / right one character
j / kMove down / up one line (logical)
gj / gkMove down / up one line (display)
w / bNext / previous word start
eEnd of current word
W / B / ESame but whitespace-delimited (WORD)
0Start of line
^First non-blank character of line
$End of line
ggStart of text (or line N)
GEnd of text (or line N)
Arrow keysMapped to hjkl in NORMAL mode

Find

KeyAction
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”:

KeyAction
dDelete
cChange (delete + enter INSERT)
yYank (copy)

Composition examples:

  • dw — delete to next word
  • d2w — delete to the 2nd word ahead
  • c$ — change from cursor to end of line
  • yy — yank entire line
  • 3dd — delete 3 lines

Line Operations

KeyAction
ddDelete entire line
ccChange entire line
yyYank entire line
DDelete to end of line (= d$)
CChange to end of line (= c$)
YYank entire line
>>Indent (2 spaces)
<<Dedent
JJoin lines

Character Operations

KeyAction
xDelete 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”:

KeyScope
iw / awWord
iW / aWWORD (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 word
  • di" — delete contents inside double quotes
  • da( — delete parentheses and their contents
  • yi{ — yank contents inside curly braces

Mode Switching

KeyAction
iInsert before cursor
IInsert at first non-blank of line
aInsert after cursor
AInsert at end of line
oOpen line below + INSERT
OOpen line above + INSERT
EscReturn to NORMAL mode

Other

KeyAction
pPaste after (linewise-aware)
PPaste before
.Dot-repeat last change
uUndo
?Help shortcut (in NORMAL idle)
1-9Count 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.

More Articles

© 2026 vincentqiao.com . All rights reserved.