vim_visual
Define text selections in a buffer by specifying start and end line and column numbers, enabling precise visual mode operations in Neovim workflows.
Instructions
Create visual mode selections in the buffer
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| endColumn | Yes | The ending column number for visual selection (0-indexed) | |
| endLine | Yes | The ending line number for visual selection (1-indexed) | |
| startColumn | Yes | The starting column number for visual selection (0-indexed) | |
| startLine | Yes | The starting line number for visual selection (1-indexed) |
Implementation Reference
- src/neovim.ts:548-567 (handler)Core implementation of vim_visual tool: enters visual mode and selects range by moving cursor from start to end position.public async visualSelect(startLine: number, startCol: number, endLine: number, endCol: number): Promise<string> { try { const nvim = await this.connect(); const window = await nvim.window; // Enter visual mode await nvim.command('normal! v'); // Move cursor to start position await (window.cursor = [startLine, startCol]); // Move cursor to end position (selection will be made) await (window.cursor = [endLine, endCol]); return 'Visual selection made'; } catch (error) { console.error('Error making visual selection:', error); return 'Error making visual selection'; } }
- src/index.ts:270-296 (registration)Registers the vim_visual tool with the MCP server, including schema and wrapper handler that delegates to NeovimManager.visualSelect.server.tool( "vim_visual", "Create visual mode selections in the buffer", { startLine: z.number().describe("The starting line number for visual selection (1-indexed)"), startColumn: z.number().describe("The starting column number for visual selection (0-indexed)"), endLine: z.number().describe("The ending line number for visual selection (1-indexed)"), endColumn: z.number().describe("The ending column number for visual selection (0-indexed)") }, async ({ startLine, startColumn, endLine, endColumn }) => { try { const result = await neovimManager.visualSelect(startLine, startColumn, endLine, endColumn); return { content: [{ type: "text", text: result }] }; } catch (error) { return { content: [{ type: "text", text: error instanceof Error ? error.message : 'Error creating visual selection' }] }; } }
- src/index.ts:273-278 (schema)Zod schema defining input parameters for the vim_visual tool.{ startLine: z.number().describe("The starting line number for visual selection (1-indexed)"), startColumn: z.number().describe("The starting column number for visual selection (0-indexed)"), endLine: z.number().describe("The ending line number for visual selection (1-indexed)"), endColumn: z.number().describe("The ending column number for visual selection (0-indexed)") },