Skip to content
This repository has been archived by the owner on Nov 26, 2023. It is now read-only.

How to change default mappings? #6

Open
NEX-S opened this issue Jun 18, 2022 · 2 comments
Open

How to change default mappings? #6

NEX-S opened this issue Jun 18, 2022 · 2 comments

Comments

@NEX-S
Copy link

NEX-S commented Jun 18, 2022

i just want to use my own keymap...

@Kurama622
Copy link

Default mappings ( https://github.com/ur4ltz/surround.nvim/blob/master/lua/surround/init.lua ):

	if vim.g.surround_mappings_style == "sandwich" then
		map("n", vim.g.surround_prefix .. vim.g.surround_prefix, "<Plug>SurroundRepeat")
		map("x", vim.g.surround_prefix,         "<Plug>SurroundAddVisual")
		map("n", vim.g.surround_prefix .. "a",  "<Plug>SurroundAddNormal")
		map("n", vim.g.surround_prefix .. "d",  "<Plug>SurroundDelete")
		map("n", vim.g.surround_prefix .. "r",  "<Plug>SurroundReplace")
		map("n", vim.g.surround_prefix .. "tq", "<Plug>SurroundToggleQuotes")
		map("n", vim.g.surround_prefix .. "tb", "<Plug>SurroundToggleBrackets")
		map("n", vim.g.surround_prefix .. "tB", "<Plug>SurroundToggleBrackets")
	elseif vim.g.surround_mappings_style == "surround" then
		map("x", "s",  "<Plug>SurroundAddVisual")
		map("n", "ys", "<Plug>SurroundAddNormal")
		map("n", "ds", "<Plug>SurroundDelete")
		map("n", "cs", "<Plug>SurroundReplace")
		map("n", "cq", "<Plug>SurroundToggleQuotes")
	end

You can refer to the following code to modify mappings:

local keymap = vim.api.nvim_set_keymap
local opts = { noremap = true, silent = true }
require"surround".setup{
    mappings_style = "surround",
    keymap("x", "S", "<Plug>SurroundAddVisual", opts)
}

@voyeg3r
Copy link

voyeg3r commented Jul 3, 2022

And how can I do, if by any chance I would like to map <C-1> to add single quotes at once?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants