io.github.iggredible/vim-mcp
编码与调试by iggredible
将 Claude Code 连接到 Vim/Neovim,可查询编辑器状态、执行命令、搜索帮助并录制 macros。
什么是 io.github.iggredible/vim-mcp?
将 Claude Code 连接到 Vim/Neovim,可查询编辑器状态、执行命令、搜索帮助并录制 macros。
README
vim-mcp
Simple MCP (Model Context Protocol) integration for Vim and Claude Code.
Features
- Connect Claude Code to one of your Vim instances
- Query Vim state (buffers, windows, cursor position, etc.)
- Execute Vim commands from Claude using natural language
How it works:
- The MCP server starts a Unix socket server at
/tmp/vim-mcp-server.sock - Each Vim instance connects to the server as a Unix socket client
- Vim sends registration and state updates to the server
- The server maintains active connections to all Vim instances
- Claude Code communicates with the MCP server via Model Context Protocol
Demo
List and select Vim instance:
<p><img src="https://github.com/user-attachments/assets/1f1e7335-b256-4b7f-be57-bf49cdee1c69" alt="List and select Vim instances" width="75%"></p>You can (finally) exit Vim!
<p><img src="https://github.com/user-attachments/assets/19436984-1464-41f8-b12a-3d15a54b79cc" alt="List and select Vim instances" width="75%"></p>For more, check out the demo wiki page
Why would anyone need this?
Ok, I get what it does, but why do we need this?
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:
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.
vim-mcp - vim_execute (MCP)(command: "g/^### /,/^#\\{1,3\\} \\|^$/s/(test foobar)/[test foobar]/g")
⎿ Command executed successfully: g/^### /,/^#\{1,3\} \|^$/s/(test foobar)/[test foobar]/g
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!
Overview
For a detailed overview, see vim-mcp overview.
Tools and Resources
Tools:
list_vim_instancesselect_vim_instanceget_vim_statevim_executeexit_vimvim_search_helpvim_record_macro
Resources:
vim://instances- List of all available Vim instancesvim://state- Current state of the selected Vim instancevim://buffers- List of all buffers in the selected Vim instancevim://tabs- List of all tabs in the selected Vim instance
Installation
Prerequisites
- Vim 8+ with
+channelfeature OR Neovim 0.5+ - Node.js 18+
- Unix domain socket support (Linux/macOS)
- File system write access to
/tmpdirectory - claude code / claude desktop or similar tools that support MCP
Install the Vim Plugin
Using vim-plug:
Plug 'iggredible/vim-mcp'
Install the MCP Server
The MCP server is a Node project. You need to install the dependencies.
Option 1: Using the Install Script
cd ~/.vim/plugged/vim-mcp # Or wherever your plugin is installed
./install.sh
The install script will automatically:
- Check prerequisites (Node.js and Vim versions)
- Install Node.js dependencies
- Attempt global installation of the
vim-mcpcommand - Show you the correct Claude Code configuration
Option 2: Manual Installation
If you prefer to install manually or the install.sh script doesn't work:
- Install Node.js dependencies:
cd ~/.vim/plugged/vim-mcp/server
npm install
npm install will also run chmod +x bin/vim-mcp
- (Optional) Install globally for system-wide
vim-mcpcommand (inside the/serverdirectory):
npm link
If this fails due to permissions or other reasons, you can skip global installation and use the full path in your config.
Configure Claude Code
After installation, add one of these configurations to your Claude configuration file:
If global install succeeded (if vim-mcp command is available):
"mcpServers": {
"vim-mcp": {
"command": "vim-mcp",
"args": []
},
}
If npm link failed:
{
"mcpServers": {
"vim-mcp": {
"command": "node",
"args": ["/some/path/.vim/plugged/vim-mcp/server/bin/vim-mcp"]
}
}
}
Uninstall
To remove vim-mcp:
- Remove the plugin from your
.vimrc:
" Delete or comment out this line:
" Plug 'iggredible/vim-mcp'
- Clean up the plugin files:
:PlugClean
- Remove the global
vim-mcpcommand (if installed):
npm unlink vim-mcp
- Remove from Claude Code configuration:
Edit the Claude config file and remove the vim-mcp section from mcpServers
- Clean up temporary files (optional):
rm -f /tmp/vim-mcp-server.sock
rm -f /tmp/vim-mcp-registry.json
rm -f /tmp/vim-mcp-preference.txt
- 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):
vim file1.txt # First instance
vim file2.txt # Second instance (in another terminal)
- In Claude Code, list available Vim instances:
list vim instances
- If multiple instances are found, select one:
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 <ex-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:
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).
Note: this is a joke tool because many people have a hard time exiting Vim.
Vim Commands
The plugin connects automatically when Vim opens. However, you can do these from inside Vim:
:VimMCPStatus- Check connection status:VimMCPConnect- Manually connect to server:VimMCPDisconnect- Disconnect from server:VimMCPReconnect- Reconnect to server
Contributing
I'm still figuring out how to make this to be more useful. If you have ideas, please feel free to submit a PR!
常见问题
io.github.iggredible/vim-mcp 是什么?
将 Claude Code 连接到 Vim/Neovim,可查询编辑器状态、执行命令、搜索帮助并录制 macros。
相关 Skills
网页构建器
by anthropics
面向复杂 claude.ai HTML artifact 开发,快速初始化 React + Tailwind CSS + shadcn/ui 项目并打包为单文件 HTML,适合需要状态管理、路由或多组件交互的页面。
✎ 在 claude.ai 里做复杂网页 Artifact 很省心,多组件、状态和路由都能顺手搭起来,React、Tailwind 与 shadcn/ui 组合效率高、成品也更精致。
前端设计
by anthropics
面向组件、页面、海报和 Web 应用开发,按鲜明视觉方向生成可直接落地的前端代码与高质感 UI,适合做 landing page、Dashboard 或美化现有界面,避开千篇一律的 AI 审美。
✎ 想把页面做得既能上线又有设计感,就用前端设计:组件到整站都能产出,难得的是能避开千篇一律的 AI 味。
网页应用测试
by anthropics
用 Playwright 为本地 Web 应用编写自动化测试,支持启动开发服务器、校验前端交互、排查 UI 异常、抓取截图与浏览器日志,适合调试动态页面和回归验证。
✎ 借助 Playwright 一站式验证本地 Web 应用前端功能,调 UI 时还能同步查看日志和截图,定位问题更快。
相关 MCP Server
GitHub
编辑精选by GitHub
GitHub 是 MCP 官方参考服务器,让 Claude 直接读写你的代码仓库和 Issues。
✎ 这个参考服务器解决了开发者想让 AI 安全访问 GitHub 数据的问题,适合需要自动化代码审查或 Issue 管理的团队。但注意它只是参考实现,生产环境得自己加固安全。
Context7 文档查询
编辑精选by Context7
Context7 是实时拉取最新文档和代码示例的智能助手,让你告别过时资料。
✎ 它能解决开发者查找文档时信息滞后的问题,特别适合快速上手新库或跟进更新。不过,依赖外部源可能导致偶尔的数据延迟,建议结合官方文档使用。
by tldraw
tldraw 是让 AI 助手直接在无限画布上绘图和协作的 MCP 服务器。
✎ 这解决了 AI 只能输出文本、无法视觉化协作的痛点——想象让 Claude 帮你画流程图或白板讨论。最适合需要快速原型设计或头脑风暴的开发者。不过,目前它只是个基础连接器,你得自己搭建画布应用才能发挥全部潜力。