vim_mark
Set named marks at specific line and column positions in a text buffer using a single lowercase letter for identification, enabling precise navigation and editing.
Instructions
Set named marks at specific positions in the buffer
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| column | Yes | The column number where the mark should be placed (0-indexed) | |
| line | Yes | The line number where the mark should be placed (1-indexed) | |
| mark | Yes | Single lowercase letter [a-z] to use as the mark name |
Implementation Reference
- src/index.ts:223-240 (handler)The MCP tool handler function for 'vim_mark' that calls NeovimManager.setMark and returns standardized content response or error message.async ({ mark, line, column }) => { try { const result = await neovimManager.setMark(mark, line, column); return { content: [{ type: "text", text: result }] }; } catch (error) { return { content: [{ type: "text", text: error instanceof Error ? error.message : 'Error setting mark' }] }; } }
- src/index.ts:218-222 (schema)Zod schema defining input parameters for the vim_mark tool: mark (lowercase letter), line and column numbers.{ mark: z.string().regex(/^[a-z]$/).describe("Single lowercase letter [a-z] to use as the mark name"), line: z.number().describe("The line number where the mark should be placed (1-indexed)"), column: z.number().describe("The column number where the mark should be placed (0-indexed)") },
- src/index.ts:215-241 (registration)Registration of the 'vim_mark' tool on the MCP server, including name, description, input schema, and handler.server.tool( "vim_mark", "Set named marks at specific positions in the buffer", { mark: z.string().regex(/^[a-z]$/).describe("Single lowercase letter [a-z] to use as the mark name"), line: z.number().describe("The line number where the mark should be placed (1-indexed)"), column: z.number().describe("The column number where the mark should be placed (0-indexed)") }, async ({ mark, line, column }) => { try { const result = await neovimManager.setMark(mark, line, column); return { content: [{ type: "text", text: result }] }; } catch (error) { return { content: [{ type: "text", text: error instanceof Error ? error.message : 'Error setting mark' }] }; } } );
- src/neovim.ts:515-530 (helper)Supporting method in NeovimManager that validates the mark name and executes the Vim 'mark' command followed by cursor positioning to the specified location.public async setMark(mark: string, line: number, col: number): Promise<string> { if (!/^[a-z]$/.test(mark)) { return 'Invalid mark name (must be a-z)'; } try { const nvim = await this.connect(); await nvim.command(`mark ${mark}`); const window = await nvim.window; await (window.cursor = [line, col]); return `Mark ${mark} set at line ${line}, column ${col}`; } catch (error) { console.error('Error setting mark:', error); return 'Error setting mark'; } }