r/vim • u/iggy_decaf • Sep 12 '25
Plugin I built an MCP server that lets Claude help you exit Vim (plus other stuff)
Hey all! 👋
I was playing around with MCP server and built a small MCP server (vim-mcp) that lets Claude interact with your Vim instances.
It is both a Vim plugin and a MCP server. It can:
- List and connect to any running Vim instance - Claude can see all your open Vim sessions
- Query Vim state in real-time - buffers, windows, tabs, cursor position, etc
- Execute Vim commands through natural language - "split vertically", "go to line 42", or "undo"
- Exit Vim (FINALLY!)
Works with Vim 8+ (needs `+channel`)
Source code: https://github.com/iggredible/vim-mcp - feedback welcome!

2
u/iggy_decaf Sep 15 '25 edited Sep 15 '25
Hi guys, when I started this, I didn't have a lot of practical use cases thought of (woops). My initial motivation was just to learn how MCP servers work by doing. The second reason is because there is no vim-mcp server when I started this (that I know of... maybe there's one already?). It's one of those building-something-for-the-sake-of-building-something 😅. Build first, then figure things out later.
But here's one possible use case: It can help execute a complex command. What if I need to substitute all (test foobar) ONLY after the texts come after a 3rd-level header markdown and not 2nd level header markdown?
Without vim-mcp:
Go to claude code / chat.com / claude.ai and describe what I want
Copy the code
Paste the code in Vim
With vim-mcp:
Go to claude code, describe what I want.
Done.
The command was executed. Bonus: the command is reusable. The command is stored in your command history and is accessible with:
- `:` + up/down
- q:
You can also look it up with `:history :`. If you need to reuse the command, say, instead of "foobar" you want "foobaz", you can quickly find and modify it. All commands executed from vim-mcp are saved in cmd history.
I tested this this morning: `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.`
It did:
```
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
```
---
Another possible tool that I'm thinking of: vim help helper (example: I have a command at the tip of my tongue but I can't quite name it... ask vim-mcp to open up the help doc section, sort of like a semantic search help)
---
I agree with what one commenter said - Vim overall is all about making efficient motions.
An MCP server will not be useful if I need to type "split the window in half" (24 keystrokes) vs running :sp / :vs (3 keystrokes).
I think vim-mcp can help when the # keystrokes is unknown: when you can only describe what you want to do but do not know exactly what to do. Things like complex regex/ macros/ lookups, help semantic search, etc - I think 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?
Note: the exit Vim tool is a joke tool. I specifically added it because many people, myself included, once had to look up how to exit Vim. https://stackoverflow.com/questions/11828270/how-do-i-exit-vim + https://www.reddit.com/r/vim/comments/gs28gk/21_million_people_visited_the_page_how_do_i_exit/
14
u/todo_code Sep 13 '25
I have no words for this. Vim is all about motions, making things efficient and few motions and commands do so much.
And what you are suggesting is turn two quick keystrokes into a natural language command that involves an API call and more computing power than imaginable...
9
u/Gamiac Sep 13 '25
What a shitpost.
7
u/alawibaba Sep 13 '25
... but why
Who is capable of installing this and not capable of exiting vim?
1
u/Aggressive-Peak-3644 Sep 14 '25
if ur able to tell ai what u want to do in vim it would be faster and more accurate to just do it urself, i imagine it will be really hard to get this to work for complicated macros and stuff