Manipulate Surroundings in Neovim

Shaik Zahid
2 min readFeb 21, 2023

--

Nvim-surround is an alternative to Vim-surround which is completely written in Lua. It offers versatility in terms of features it provide the enhance the developer experience in Neovim. It comes in very handy at times where we are working on a project with bigger sizes.

Requirements

Neovim ≥ 0.8

Installation

  • Add the repository of Nvim-Surround in plugins.lua file and install it using shift + i .
-- plugins.lua 

return {

-- Alpha (Dashboard)
{
"goolord/alpha-nvim",
lazy = true,
},


-- Auto Pairs
{
"windwp/nvim-autopairs"
},

-- Bufferline
{
'akinsho/bufferline.nvim',
dependencies = {
'nvim-tree/nvim-web-devicons'
},
},

-- Colorscheme
{
'folke/tokyonight.nvim',
},

-- Hop (Better Navigation)
{
"phaazon/hop.nvim",
lazy = true,
},


-- Lualine
{
'nvim-lualine/lualine.nvim',
dependencies = {
'nvim-tree/nvim-web-devicons'
},
},


-- Language Support
{
'VonHeikemen/lsp-zero.nvim',
lazy = true,
branch = 'v1.x',
dependencies = {
-- LSP Support
{'neovim/nvim-lspconfig'}, -- Required
{'williamboman/mason.nvim'}, -- Optional
{'williamboman/mason-lspconfig.nvim'}, -- Optional

-- Autocompletion
{'hrsh7th/nvim-cmp'}, -- Required
{'hrsh7th/cmp-nvim-lsp'}, -- Required
{'hrsh7th/cmp-buffer'}, -- Optional
{'hrsh7th/cmp-path'}, -- Optional
{'saadparwaiz1/cmp_luasnip'}, -- Optional
{'hrsh7th/cmp-nvim-lua'}, -- Optional

-- Snippets
{'L3MON4D3/LuaSnip'}, -- Required
{'rafamadriz/friendly-snippets'}, -- Optional
}
},


-- Nvim-tree (File Explorer)
{
'nvim-tree/nvim-tree.lua',
lazy = true,
dependencies = {
'nvim-tree/nvim-web-devicons',
},
},


-- Nvim-Surround (Manipulating Surroundings)
-- Installed this plugin
{
"kylechui/nvim-surround",
config = function()
require("nvim-surround").setup({
-- Configuration here, or leave empty to use defaults
})
end
},


-- Telescope (Fuzzy Finder)
{
'nvim-telescope/telescope.nvim',
lazy = true,
dependencies = {
{'nvim-lua/plenary.nvim'},
}
},


-- Treesitter
{
"nvim-treesitter/nvim-treesitter",
},


-- Toggle Term
{
'akinsho/toggleterm.nvim',
config = true
},

-- Which-key
{
'folke/which-key.nvim',
lazy = true,
},

}
  • There is nothing to configure this plugin, all we need to do is to learn how to use it.

Keybindings

  • The keybindings are explained in detail in the documentation well written when implementing this plugin. You can find it by navigating through this link of their github repository.

Neovim From Scratch

  • If you want a complete installation and configuration of Neovim from Scratch, then you can head over to my NEOVIM SERIES.
  • This series is updated regularly, with updates and inclusion of newer plugins which improves the wholesome IDE experience of Neovim.

--

--