vim_window
Split, close, and navigate Neovim windows using commands like split, vsplit, only, close, and wincmd with h/j/k/l for efficient window management.
Instructions
Manage Neovim windows: split, close, and navigate between windows
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| command | Yes | Window manipulation command: split or vsplit to create new window, only to keep just current window, close to close current window, or wincmd with h/j/k/l to navigate between windows |
Implementation Reference
- src/neovim.ts:499-513 (handler)Core handler function that validates the command and executes it directly on the Neovim instance using nvim.command().public async manipulateWindow(command: string): Promise<string> { const validCommands = ['split', 'vsplit', 'only', 'close', 'wincmd h', 'wincmd j', 'wincmd k', 'wincmd l']; if (!validCommands.some(cmd => command.startsWith(cmd))) { return 'Invalid window command'; } try { const nvim = await this.connect(); await nvim.command(command); return 'Window command executed'; } catch (error) { console.error('Error manipulating window:', error); return 'Error executing window command'; } }
- src/index.ts:188-213 (registration)MCP server registration of the 'vim_window' tool, including description, input schema, and wrapper handler that calls the core implementation.server.tool( "vim_window", "Manage Neovim windows: split, close, and navigate between windows", { command: z.enum(["split", "vsplit", "only", "close", "wincmd h", "wincmd j", "wincmd k", "wincmd l"]) .describe("Window manipulation command: split or vsplit to create new window, only to keep just current window, close to close current window, or wincmd with h/j/k/l to navigate between windows") }, async ({ command }) => { try { const result = await neovimManager.manipulateWindow(command); return { content: [{ type: "text", text: result }] }; } catch (error) { return { content: [{ type: "text", text: error instanceof Error ? error.message : 'Error manipulating window' }] }; } } );
- src/index.ts:191-194 (schema)Zod input schema defining the allowed 'command' enum values for the vim_window tool.{ command: z.enum(["split", "vsplit", "only", "close", "wincmd h", "wincmd j", "wincmd k", "wincmd l"]) .describe("Window manipulation command: split or vsplit to create new window, only to keep just current window, close to close current window, or wincmd with h/j/k/l to navigate between windows") },