nvim-surround lets you add, delete, and change delimiter pairs around text in Neovim using motion-based keymaps. It supports common pairs, function calls, HTML tags, and custom configuration written in Lua.
Overview
nvim-surround is a Neovim plugin for working with surrounding characters around the cursor or a visual selection. The core operations mirror classic surround workflows: add with ys, delete with ds, and change with cs, combined with a motion and a pair specifier.
Out of the box it handles delimiter pairs, function-call style surrounds, and HTML tags. You can repeat the last action with dot, define buffer-local mappings and custom surrounds, and jump to the nearest pair when editing. Single-character aliases can stand in for several text objects, such as mapping q to quote-like objects.
The plugin integrates with Vim motions, Lua patterns, and Tree-sitter nodes when available. With nvim-treesitter-textobjects installed, Tree-sitter can define surrounds to simplify configuration. Selections can be highlighted for feedback while you operate.
Installation is through a Neovim plugin manager such as lazy.nvim or vim.pack. Configuration runs through require("nvim-surround").setup or buffer-local setup calls documented in the built-in help files.
Key features
- Add, delete, and change surrounds
- Function calls and HTML tags
- Dot-repeat last surround action
- Buffer-local mappings and surrounds
- Jump to nearest surround pair
- Alias one key to several objects
- Vim, Lua, and Tree-sitter motions
- Visual highlight while operating
Use cases
- Wrap code selections in parentheses
- Swap quote types around strings
- Surround tags in markup buffers
- Custom paired delimiters per project
- Fast structural editing in Neovim