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")
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but offers minimal behavioral context. It doesn't mention whether this operation is safe, what happens if the identifier doesn't exist, whether it changes the current view, or any side effects. The description only states the basic action without behavioral details.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It's appropriately sized for a simple tool and front-loads the essential information without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what happens after switching buffers, what errors might occur, or how to verify the switch succeeded. Given the lack of structured metadata, more behavioral context would be needed for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents the identifier parameter fully. The description adds minimal value by mentioning 'by name or number' which aligns with the schema's union type, but doesn't provide additional syntax, format, or usage details beyond what's in the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('switch') and resource ('buffers') with the mechanism ('by name or number'), making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like vim_buffer or vim_tab, but the specificity of buffer switching is reasonably distinct within the Vim context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like vim_tab (for tab switching) or vim_window (for window switching). The description states what it does but offers no context about appropriate use cases or prerequisites for buffer switching.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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