[](https://github.com/echasnovski/mini.nvim/blob/main/LICENSE)
### Fast and feature-rich surround actions
- Add, delete, replace, find, highlight surrounding (like pair of parenthesis, quotes, etc.).
- Supports dot-repeat, `v:count`, different search methods, "last"/"next" extended mappings, customization via Lua patterns or functions, and more.
- Has builtins for brackets, function call, tag, user prompt, and any alphanumeric/punctuation/whitespace character.
- Has maintained configuration of setup similar to 'tpope/vim-surround'.
See more details in [Features](#features) and [help file](../doc/mini-surround.txt).
---
⦿ This is a part of [mini.nvim](https://github.com/echasnovski/mini.nvim) library. Please use [this link](https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-surround.md) if you want to mention this module.
⦿ All contributions (issues, pull requests, discussions, etc.) are done inside of 'mini.nvim'.
⦿ See the repository page to learn about common design principles and configuration recipes.
---
If you want to help this project grow but don't know where to start, check out [contributing guides of 'mini.nvim'](https://github.com/echasnovski/mini.nvim/blob/main/CONTRIBUTING.md) or leave a Github star for 'mini.nvim' project and/or any its standalone Git repositories.
## Demo
https://user-images.githubusercontent.com/24854248/173045302-cc4fd421-cc33-4924-a95b-207097973b48.mp4
## Features
- Actions (all of them are dot-repeatable out of the box and respect `v:count` for searching surrounding) with configurable keymappings:
- Add surrounding with `sa` (in visual mode or on motion).
- Delete surrounding with `sd`.
- Replace surrounding with `sr`.
- Find surrounding with `sf` or `sF` (move cursor right or left).
- Highlight surrounding with `sh`.
- Change number of neighbor lines with `sn` (see |MiniSurround-algorithm|).
- Surrounding is identified by a single character as both "input" (in `delete` and `replace` start, `find`, and `highlight`) and "output" (in `add` and `replace` end):
- 'f' - function call (string of alphanumeric symbols or '_' or '.' followed by balanced '()'). In "input" finds function call, in "output" prompts user to enter function name.
- 't' - tag. In "input" finds tag with same identifier, in "output" prompts user to enter tag name.
- All symbols in brackets '()', '[]', '{}', '<>". In "input' represents balanced brackets (open - with whitespace pad, close - without), in "output" - left and right parts of brackets.
- '?' - interactive. Prompts user to enter left and right parts.
- All other alphanumeric, punctuation, or space characters represent surrounding with identical left and right parts.
- Configurable search methods to find not only covering but possibly next, previous, or nearest surrounding. See more in help for `MiniSurround.config`.
- All actions involving finding surrounding (delete, replace, find, highlight) can be used with suffix that changes search method to find previous/last. See more in help for `MiniSurround.config`.
## Installation
This plugin can be installed as part of 'mini.nvim' library (**recommended**) or as a standalone Git repository.
There are two branches to install from:
- `main` (default, **recommended**) will have latest development version of plugin. All changes since last stable release should be perceived as being in beta testing phase (meaning they already passed alpha-testing and are moderately settled).
- `stable` will be updated only upon releases with code tested during public beta-testing phase in `main` branch.
Here are code snippets for some common installation methods (use only one):
| Github repo | Branch | Code snippet |
|---|---|---|
| 'mini.nvim' library | Main | Follow recommended 'mini.deps' installation |
| Stable | ||
| Standalone plugin | Main | add('echasnovski/mini.surround') |
| Stable | add({ source = 'echasnovski/mini.surround', checkout = 'stable' }) |
| Github repo | Branch | Code snippet |
|---|---|---|
| 'mini.nvim' library | Main | { 'echasnovski/mini.nvim', version = false }, |
| Stable | { 'echasnovski/mini.nvim', version = '*' }, |
|
| Standalone plugin | Main | { 'echasnovski/mini.surround', version = false }, |
| Stable | { 'echasnovski/mini.surround', version = '*' }, |
| Github repo | Branch | Code snippet |
|---|---|---|
| 'mini.nvim' library | Main | Plug 'echasnovski/mini.nvim' |
| Stable | Plug 'echasnovski/mini.nvim', { 'branch': 'stable' } |
|
| Standalone plugin | Main | Plug 'echasnovski/mini.surround' |
| Stable | Plug 'echasnovski/mini.surround', { 'branch': 'stable' } |