Connect Claude Code to Vim/Neovim - query state, execute commands, search help, record macros
A Model Context Protocol (MCP) server that connects Claude Code to Vim/Neovim. It exposes Vim state, supports executing commands, searching help, and recording macros via a Unix socket-based server, enabling multi-instance awareness and remote control.
🛠️ Key Features
Unix socket MCP server at /tmp/vim-mcp-server.sock
Connect Claude Code to Vim instances
Query Vim state: buffers, windows, cursor position, etc.
Execute Vim commands from Claude using natural language
Maintain active connections to all Vim instances
Vim/Neovim integration via simple, lightweight protocol
🚀 Use Cases
Multi-instance Vim setups with centralized MCP server
Claude Code querying real-time Vim state during coding
Natural-language command execution of Vim actions
State synchronization across connected Vim instances
⚡ Developer Benefits
Clear MCP wiring: server starts, clients register, state updates
Straightforward socket-based communication model
Extendable to additional Vim state signals and commands
⚠️ Limitations
Data relies on Vim/Neovim client connections to the Unix socket
Description focuses on core features; implementation details may vary
Documentation excerpt shows initial workflow; full behavior depends on client support
If you're trying to do basic Vim operations like typing "split the window in half" (24 keystrokes) vs running :sp / :vs (3 keystrokes), then you're better off without it. Where vim-mcp shines is when the number of keystrokes is unknown; when you can only describe what you want to do but don't know exactly how to do it. Things like complex regex/macros/lookups, help semantic search, etc. - it's faster to tell AI what you're trying to accomplish than trial-and-error. I think the word I'm looking for is circumlocution?
Here's one scenario where it may be useful:
Suppose you want to perform a complex Vim command that would otherwise take a long time to construct. Claude can easily do it if you can describe what you want to do. Maybe you want to substitute "(test foobar)" with square brackets ONLY IF they come after a 3rd-level Markdown header. That's not something I can easily cook up in seconds... but Claude can!
With vim-mcp, I can prompt Claude:
code
In README.md, substitute the set of parentheses `(SOME TEXT)` with square brackets `[SOME TEXT]`, where SOME TEXT says "test foobar"; do this if the strings come after a 3rd-level header markdown.
And that's it! When I did it, Claude came up with the g command and executed it for me.
Bonus: the executed commands are stored in the command history so you can go back and re-execute them or modify them.
What if you later decide, "Hey, I actually don't want to substitute them with square brackets [], I want to substitute them with curly brackets {} instead!" You can just access the command history (q:, :history, or : then press up/down) and make the necessary modifications.
So I did :, then pressed the up arrow a few times until I saw the command that vim-mcp executed, and changed it to :g/^### /,/^#\{1,3\} \|^$/s/(test foobar)/{test foobar}/g. Done!
Restart Vim and Claude Code to ensure all connections are cleared.
Quick Start
Step-by-Step Connection Process
Open Vim instances (the plugin connects automatically):
bash
vim file1.txt # First instance
vim file2.txt # Second instance (in another terminal)
In Claude Code, list available Vim instances:
code
list vim instances
If multiple instances are found, select one:
code
select vim instance file1-vim-12345
Things you can prompt
From the client (claude code), you can:
Manage instances:
"List vim instances"
"Connect to the first one pls"
"Select the one with README.md open"
Control Vim:
"Split into two windows vertically"
"execute vim command "
"HELP ME EXIT VIM!!!"
Search Vim help:
"Search vim help for working with channels"
"How do I use vim's quickfix list?"
"Show me help on vim registers"
Record macros:
"Record a macro that uppercases the first word and moves down 2 lines"
"Create a macro to duplicate the current line and comment it out"
"Make a macro that finds the next TODO and marks it as DONE"
Query about Vim:
"How many buffers do I have?"
"What buffers are open?"
"What is my cursor position?"
"Show me the current buffer content"
"How many lines are in the active buffer?"
"What language is the file written in?"
"What windows are open?"
"What is the realistic 10-year target price for BTC?" (jk)
vim-mcp can help you exit Vim!!
You can FINALLY exit Vim! Rejoice! The exit_vim tool provides safe exit functionality with three modes:
Default (check): Checks for unsaved changes and warns you before exiting
Save and exit: Saves all modified buffers and exits (exit vim save_and_exit)
Force exit: Exits without saving, discarding changes (exit vim force_exit)
Examples:
code
exit vim # Safe exit - warns about unsaved changes
exit vim save_and_exit # Save all files and exit
exit vim force_exit # Exit without saving (discard changes)
GET ME OUTTA HERE # You're free! Successfully exited Vim (there were no unsaved changes).