Skip to main content
Glama

vim_macro

Record, stop, and play Neovim macros using specific registers and counts to automate repetitive text editing tasks in your workflow.

Instructions

Record, stop, and play Neovim macros

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesAction to perform with macros
countNoNumber of times to play macro (default: 1)
registerNoRegister to record/play macro (a-z, required for record/play)

Implementation Reference

  • Core handler implementation for vim_macro tool. Handles 'record', 'stop', and 'play' actions by sending appropriate Neovim input sequences (q<register>, q, @<register>).
    public async manageMacro(action: string, register?: string, count: number = 1): Promise<string> { try { const nvim = await this.connect(); switch (action) { case 'record': if (!register || register.length !== 1 || !/[a-z]/.test(register)) { throw new NeovimValidationError('Register must be a single letter a-z for recording'); } await nvim.input(`q${register}`); return `Started recording macro in register '${register}'`; case 'stop': await nvim.input('q'); return 'Stopped recording macro'; case 'play': if (!register || register.length !== 1 || !/[a-z]/.test(register)) { throw new NeovimValidationError('Register must be a single letter a-z for playing'); } const playCommand = count > 1 ? `${count}@${register}` : `@${register}`; await nvim.input(playCommand); return `Played macro from register '${register}' ${count} time(s)`; default: throw new NeovimValidationError(`Unknown macro action: ${action}`); } } catch (error) { if (error instanceof NeovimValidationError) { throw error; } console.error('Error managing macro:', error); throw new NeovimCommandError(`macro ${action}`, error instanceof Error ? error.message : 'Unknown error'); } }
  • src/index.ts:481-507 (registration)
    Registers the vim_macro tool with MCP server, including schema definition and thin handler delegating to neovimManager.manageMacro.
    server.tool( "vim_macro", "Record, stop, and play Neovim macros", { action: z.enum(["record", "stop", "play"]).describe("Action to perform with macros"), register: z.string().optional().describe("Register to record/play macro (a-z, required for record/play)"), count: z.number().optional().describe("Number of times to play macro (default: 1)") }, async ({ action, register, count = 1 }) => { try { const result = await neovimManager.manageMacro(action, register, count); return { content: [{ type: "text", text: result }] }; } catch (error) { return { content: [{ type: "text", text: error instanceof Error ? error.message : 'Error managing macro' }] }; } } );
  • Zod schema defining input parameters for vim_macro: action (enum: record/stop/play), optional register (string), optional count (number).
    { action: z.enum(["record", "stop", "play"]).describe("Action to perform with macros"), register: z.string().optional().describe("Register to record/play macro (a-z, required for record/play)"), count: z.number().optional().describe("Number of times to play macro (default: 1)")

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