# nvim-surround Surround selections, stylishly :sunglasses:
\`,',"
, so csqb
replaces
the _nearest_ set of quotes with parentheses
- Surround using powerful pairs that depend on user input
- Modify custom surrounds
- First-class support for Vim motions, Lua patterns, and Tree-sitter nodes
- Highlight selections for visual feedback
## :lock: Requirements
- [Neovim 0.8+](https://github.com/neovim/neovim/releases)
- \[Recommended] If
[nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) is
installed, then Tree-sitter nodes may be surrounded and modified, in addition
to just Vim motions and Lua patterns
- \[Recommended] If
[nvim-treesitter-textobjects](https://github.com/nvim-treesitter/nvim-treesitter-textobjects)
is installed, then Tree-sitter text-objects can be used to define surrounds,
simplifying configuration
## :package: Installation
Install this plugin using your favorite plugin manager, and then call
`require("nvim-surround").setup()`.
### [lazy.nvim](https://github.com/folke/lazy.nvim)
```lua
{
"kylechui/nvim-surround",
version = "*", -- Use for stability; omit to use `main` branch for the latest features
event = "VeryLazy",
config = function()
require("nvim-surround").setup({
-- Configuration here, or leave empty to use defaults
})
end
}
```
### [packer.nvim](https://github.com/wbthomason/packer.nvim)
```lua
use({
"kylechui/nvim-surround",
tag = "*", -- Use for stability; omit to use `main` branch for the latest features
config = function()
require("nvim-surround").setup({
-- Configuration here, or leave empty to use defaults
})
end
})
```
## :rocket: Usage
The three "core" operations of `add`/`delete`/`change` can be done with the
keymaps `ys{motion}{char}`, `ds{char}`, and `cs{target}{replacement}`,
respectively. For the following examples, `*` will denote the cursor position:
```help
Old text Command New text
--------------------------------------------------------------------------------
surr*ound_words ysiw) (surround_words)
*make strings ys$" "make strings"
[delete ar*ound me!] ds] delete around me!
remove HTML t*ags dst remove HTML tags
'change quot*es' cs'" "change quotes"
or tag* types csth1