vim_tab
Command Neovim tabs directly: create, close, navigate, or list open tabs. Simplify tab management for efficient editing workflows.
Instructions
Manage Neovim tabs: create, close, and navigate between tabs
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | Tab action to perform | |
| filename | No | Filename for new tab (optional) |
Implementation Reference
- src/index.ts:517-534 (handler)Tool handler function for vim_tab that calls neovimManager.manageTab and handles response/error formatting.async ({ action, filename }) => { try { const result = await neovimManager.manageTab(action, filename); return { content: [{ type: "text", text: result }] }; } catch (error) { return { content: [{ type: "text", text: error instanceof Error ? error.message : 'Error managing tab' }] }; } }
- src/index.ts:513-515 (schema)Zod input schema defining parameters for the vim_tab tool: action enum and optional filename.{ action: z.enum(["new", "close", "next", "prev", "first", "last", "list"]).describe("Tab action to perform"), filename: z.string().optional().describe("Filename for new tab (optional)")
- src/index.ts:510-535 (registration)MCP server.tool registration for 'vim_tab' including name, description, schema, and handler.server.tool( "vim_tab", "Manage Neovim tabs: create, close, and navigate between tabs", { action: z.enum(["new", "close", "next", "prev", "first", "last", "list"]).describe("Tab action to perform"), filename: z.string().optional().describe("Filename for new tab (optional)") }, async ({ action, filename }) => { try { const result = await neovimManager.manageTab(action, filename); return { content: [{ type: "text", text: result }] }; } catch (error) { return { content: [{ type: "text", text: error instanceof Error ? error.message : 'Error managing tab' }] }; } } );
- src/neovim.ts:822-880 (helper)Core helper method in NeovimManager implementing all vim_tab actions using direct Neovim API commands.public async manageTab(action: string, filename?: string): Promise<string> { try { const nvim = await this.connect(); switch (action) { case 'new': if (filename) { await nvim.command(`tabnew ${filename}`); return `Created new tab with file: ${filename}`; } else { await nvim.command('tabnew'); return 'Created new empty tab'; } case 'close': await nvim.command('tabclose'); return 'Closed current tab'; case 'next': await nvim.command('tabnext'); return 'Moved to next tab'; case 'prev': await nvim.command('tabprev'); return 'Moved to previous tab'; case 'first': await nvim.command('tabfirst'); return 'Moved to first tab'; case 'last': await nvim.command('tablast'); return 'Moved to last tab'; case 'list': const tabs = await nvim.tabpages; const tabInfo = []; for (let i = 0; i < tabs.length; i++) { const tab = tabs[i]; const win = await tab.window; const buf = await win.buffer; const name = await buf.name; const current = await nvim.tabpage; const isCurrent = tab === current; tabInfo.push(`${isCurrent ? '*' : ' '}${i + 1}: ${name || '[No Name]'}`); } return `Tabs:\n${tabInfo.join('\n')}`; default: throw new NeovimValidationError(`Unknown tab action: ${action}`); } } catch (error) { if (error instanceof NeovimValidationError) { throw error; } console.error('Error managing tab:', error); throw new NeovimCommandError(`tab ${action}`, error instanceof Error ? error.message : 'Unknown error'); } }