Skip to content

Commit 83468be

Browse files
authored
fix(keymap): remove select mode remaps of printable characters (#6296)
## Description Most of the "visual mode" mappings use "v" instead of "x", and therefore also affect select mode. If the key is a printable character, it is now unusable in select mode. This is most prominent with `<leader>`, which is space by default, a printable character. The most common use of select mode is when it is automatically triggered by snippets. Currently, trying to type space, g, <, >, etc. as the first character of a snippet field will trigger their bind instead of actually inserting the character. I cannot currently think of any good reason why anyone would rely on using select mode to execute any of these mapped actions. ## Checklist - [x] I've read the [CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md) guidelines.
1 parent f118dca commit 83468be

File tree

13 files changed

+28
-28
lines changed

13 files changed

+28
-28
lines changed

lua/lazyvim/config/keymaps.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ map({ "i", "x", "n", "s" }, "<C-s>", "<cmd>w<cr><esc>", { desc = "Save File" })
8181
map("n", "<leader>K", "<cmd>norm! K<cr>", { desc = "Keywordprg" })
8282

8383
-- better indenting
84-
map("v", "<", "<gv")
85-
map("v", ">", ">gv")
84+
map("x", "<", "<gv")
85+
map("x", ">", ">gv")
8686

8787
-- commenting
8888
map("n", "gco", "o<esc>Vcx<esc><cmd>normal gcc<cr>fxa<bs>", { desc = "Add Comment Below" })
@@ -114,7 +114,7 @@ map("n", "[q", vim.cmd.cprev, { desc = "Previous Quickfix" })
114114
map("n", "]q", vim.cmd.cnext, { desc = "Next Quickfix" })
115115

116116
-- formatting
117-
map({ "n", "v" }, "<leader>cf", function()
117+
map({ "n", "x" }, "<leader>cf", function()
118118
LazyVim.format({ force = true })
119119
end, { desc = "Format" })
120120

lua/lazyvim/plugins/editor.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ return {
1818
},
1919
})
2020
end,
21-
mode = { "n", "v" },
21+
mode = { "n", "x" },
2222
desc = "Search and Replace",
2323
},
2424
},
@@ -64,7 +64,7 @@ return {
6464
defaults = {},
6565
spec = {
6666
{
67-
mode = { "n", "v" },
67+
mode = { "n", "x" },
6868
{ "<leader><tab>", group = "tabs" },
6969
{ "<leader>c", group = "code" },
7070
{ "<leader>d", group = "debug" },
@@ -173,8 +173,8 @@ return {
173173
end, "Prev Hunk")
174174
map("n", "]H", function() gs.nav_hunk("last") end, "Last Hunk")
175175
map("n", "[H", function() gs.nav_hunk("first") end, "First Hunk")
176-
map({ "n", "v" }, "<leader>ghs", ":Gitsigns stage_hunk<CR>", "Stage Hunk")
177-
map({ "n", "v" }, "<leader>ghr", ":Gitsigns reset_hunk<CR>", "Reset Hunk")
176+
map({ "n", "x" }, "<leader>ghs", ":Gitsigns stage_hunk<CR>", "Stage Hunk")
177+
map({ "n", "x" }, "<leader>ghr", ":Gitsigns reset_hunk<CR>", "Reset Hunk")
178178
map("n", "<leader>ghS", gs.stage_buffer, "Stage Buffer")
179179
map("n", "<leader>ghu", gs.undo_stage_hunk, "Undo Stage Hunk")
180180
map("n", "<leader>ghR", gs.reset_buffer, "Reset Buffer")

lua/lazyvim/plugins/extras/ai/copilot-chat.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,22 @@ return {
2020
end,
2121
keys = {
2222
{ "<c-s>", "<CR>", ft = "copilot-chat", desc = "Submit Prompt", remap = true },
23-
{ "<leader>a", "", desc = "+ai", mode = { "n", "v" } },
23+
{ "<leader>a", "", desc = "+ai", mode = { "n", "x" } },
2424
{
2525
"<leader>aa",
2626
function()
2727
return require("CopilotChat").toggle()
2828
end,
2929
desc = "Toggle (CopilotChat)",
30-
mode = { "n", "v" },
30+
mode = { "n", "x" },
3131
},
3232
{
3333
"<leader>ax",
3434
function()
3535
return require("CopilotChat").reset()
3636
end,
3737
desc = "Clear (CopilotChat)",
38-
mode = { "n", "v" },
38+
mode = { "n", "x" },
3939
},
4040
{
4141
"<leader>aq",
@@ -49,15 +49,15 @@ return {
4949
end)
5050
end,
5151
desc = "Quick Chat (CopilotChat)",
52-
mode = { "n", "v" },
52+
mode = { "n", "x" },
5353
},
5454
{
5555
"<leader>ap",
5656
function()
5757
require("CopilotChat").select_prompt()
5858
end,
5959
desc = "Prompt Actions (CopilotChat)",
60-
mode = { "n", "v" },
60+
mode = { "n", "x" },
6161
},
6262
},
6363
config = function(_, opts)

lua/lazyvim/plugins/extras/coding/mini-surround.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ return {
88
-- Populate the keys based on the user's options
99
local opts = LazyVim.opts("mini.surround")
1010
local mappings = {
11-
{ opts.mappings.add, desc = "Add Surrounding", mode = { "n", "v" } },
11+
{ opts.mappings.add, desc = "Add Surrounding", mode = { "n", "x" } },
1212
{ opts.mappings.delete, desc = "Delete Surrounding" },
1313
{ opts.mappings.find, desc = "Find Right Surrounding" },
1414
{ opts.mappings.find_left, desc = "Find Left Surrounding" },

lua/lazyvim/plugins/extras/dap/core.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ return {
8484
-- stylua: ignore
8585
keys = {
8686
{ "<leader>du", function() require("dapui").toggle({ }) end, desc = "Dap UI" },
87-
{ "<leader>de", function() require("dapui").eval() end, desc = "Eval", mode = {"n", "v"} },
87+
{ "<leader>de", function() require("dapui").eval() end, desc = "Eval", mode = {"n", "x"} },
8888
},
8989
opts = {},
9090
config = function(_, opts)

lua/lazyvim/plugins/extras/editor/dial.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ return {
1919
keys = {
2020
{ "<C-a>", function() return M.dial(true) end, expr = true, desc = "Increment", mode = {"n", "v"} },
2121
{ "<C-x>", function() return M.dial(false) end, expr = true, desc = "Decrement", mode = {"n", "v"} },
22-
{ "g<C-a>", function() return M.dial(true, true) end, expr = true, desc = "Increment", mode = {"n", "v"} },
23-
{ "g<C-x>", function() return M.dial(false, true) end, expr = true, desc = "Decrement", mode = {"n", "v"} },
22+
{ "g<C-a>", function() return M.dial(true, true) end, expr = true, desc = "Increment", mode = {"n", "x"} },
23+
{ "g<C-x>", function() return M.dial(false, true) end, expr = true, desc = "Decrement", mode = {"n", "x"} },
2424
},
2525
opts = function()
2626
local augend = require("dial.augend")

lua/lazyvim/plugins/extras/editor/fzf.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ return {
253253
{ "<leader>sq", "<cmd>FzfLua quickfix<cr>", desc = "Quickfix List" },
254254
{ "<leader>sw", LazyVim.pick("grep_cword"), desc = "Word (Root Dir)" },
255255
{ "<leader>sW", LazyVim.pick("grep_cword", { root = false }), desc = "Word (cwd)" },
256-
{ "<leader>sw", LazyVim.pick("grep_visual"), mode = "v", desc = "Selection (Root Dir)" },
257-
{ "<leader>sW", LazyVim.pick("grep_visual", { root = false }), mode = "v", desc = "Selection (cwd)" },
256+
{ "<leader>sw", LazyVim.pick("grep_visual"), mode = "x", desc = "Selection (Root Dir)" },
257+
{ "<leader>sW", LazyVim.pick("grep_visual", { root = false }), mode = "x", desc = "Selection (cwd)" },
258258
{ "<leader>uC", LazyVim.pick("colorschemes"), desc = "Colorscheme with Preview" },
259259
{
260260
"<leader>ss",

lua/lazyvim/plugins/extras/editor/telescope.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ return {
136136
{ "<leader>sq", "<cmd>Telescope quickfix<cr>", desc = "Quickfix List" },
137137
{ "<leader>sw", LazyVim.pick("grep_string", { word_match = "-w" }), desc = "Word (Root Dir)" },
138138
{ "<leader>sW", LazyVim.pick("grep_string", { root = false, word_match = "-w" }), desc = "Word (cwd)" },
139-
{ "<leader>sw", LazyVim.pick("grep_string"), mode = "v", desc = "Selection (Root Dir)" },
140-
{ "<leader>sW", LazyVim.pick("grep_string", { root = false }), mode = "v", desc = "Selection (cwd)" },
139+
{ "<leader>sw", LazyVim.pick("grep_string"), mode = "x", desc = "Selection (Root Dir)" },
140+
{ "<leader>sW", LazyVim.pick("grep_string", { root = false }), mode = "x", desc = "Selection (cwd)" },
141141
{ "<leader>uC", LazyVim.pick("colorscheme", { enable_preview = true }), desc = "Colorscheme with Preview" },
142142
{
143143
"<leader>ss",

lua/lazyvim/plugins/extras/lang/clojure.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ return {
7676
end
7777

7878
vim.keymap.set(
79-
{ "n", "v" },
79+
{ "n", "x" },
8080
"[c",
8181
"<CMD>call search('^; -\\+$', 'bw')<CR>",
8282
{ silent = true, buffer = true, desc = "Jumps to the begining of previous evaluation output." }
8383
)
8484
vim.keymap.set(
85-
{ "n", "v" },
85+
{ "n", "x" },
8686
"]c",
8787
"<CMD>call search('^; -\\+$', 'w')<CR>",
8888
{ silent = true, buffer = true, desc = "Jumps to the begining of next evaluation output." }

lua/lazyvim/plugins/extras/lang/java.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ return {
209209
})
210210
wk.add({
211211
{
212-
mode = "v",
212+
mode = "x",
213213
buffer = args.buf,
214214
{ "<leader>cx", group = "extract" },
215215
{

0 commit comments

Comments
 (0)