Skip to main content
Glama

vim_buffer_switch

Quickly switch between buffers in Neovim using buffer numbers or filenames, streamlining navigation and enhancing productivity in text editing workflows.

Instructions

Switch between buffers by name or number

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
identifierYesBuffer identifier - can be buffer number or filename/path

Implementation Reference

  • src/index.ts:300-324 (registration)
    Registers the 'vim_buffer_switch' MCP tool, including input schema and inline handler that calls NeovimManager.switchBuffer
    server.tool( "vim_buffer_switch", "Switch between buffers by name or number", { identifier: z.union([z.string(), z.number()]).describe("Buffer identifier - can be buffer number or filename/path") }, async ({ identifier }) => { try { const result = await neovimManager.switchBuffer(identifier); return { content: [{ type: "text", text: result }] }; } catch (error) { return { content: [{ type: "text", text: error instanceof Error ? error.message : 'Error switching buffer' }] }; } } );
  • The core handler logic for switching Neovim buffers by number or name/path in NeovimManager class
    public async switchBuffer(identifier: string | number): Promise<string> { try { const nvim = await this.connect(); // If identifier is a number, switch by buffer number if (typeof identifier === 'number') { await nvim.command(`buffer ${identifier}`); return `Switched to buffer ${identifier}`; } // If identifier is a string, try to find buffer by name const buffers = await nvim.buffers; for (const buffer of buffers) { const bufName = await buffer.name; if (bufName === identifier || bufName.endsWith(identifier)) { await nvim.command(`buffer ${buffer.id}`); return `Switched to buffer: ${bufName}`; } } throw new NeovimValidationError(`Buffer not found: ${identifier}`); } catch (error) { if (error instanceof NeovimValidationError) { throw error; } console.error('Error switching buffer:', error); throw new NeovimCommandError(`buffer switch to ${identifier}`, error instanceof Error ? error.message : 'Unknown error'); } }
  • Zod schema defining the input parameter for the vim_buffer_switch tool
    { identifier: z.union([z.string(), z.number()]).describe("Buffer identifier - can be buffer number or filename/path") },

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bigcodegen/mcp-neovim-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server