Skip to main content
Glama

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
NameRequiredDescriptionDefault
actionYesTab action to perform
filenameNoFilename for new tab (optional)

Implementation Reference

  • 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'
          }]
        };
      }
    }
  • 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'
            }]
          };
        }
      }
    );
  • 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');
      }
    }
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