Closed Penguin-SAMA closed 2 months ago
Not user/plugins/visual-multi.lua
but user/plugins/editor.lua
.
Now my config is as follows, but it still doesn't work.
user/plugins/editor.lua
custom["mg979/vim-visual-multi"] = {
lazy = true,
event = "BufReadPost",
config = require("configs.visual-multi.visual-multi"),
}
user/configs/visual-multi/visual-multi.lua
return function()
vim.g.VM_maps["Find Under"] = "<C-d>" -- replace C-n
vim.g.VM_maps["Find Subword Under"] = "<C-d>" -- replace visual C-n
vim.g.VM_mouse_mappings = 1
end
Sorry, I've looked at this wiki page and I've tried the following two modifications and it still doesn't work. I don't know much about the configuration method of vim plug-in, so I don't know how to fill in the keymap.
user/configs/visual-multi/visual-multi.lua
return function()
vim.g.VM_maps["Find Under"] = "<C-d>" -- replace C-n
vim.g.VM_maps["Find Subword Under"] = "<C-d>" -- replace visual C-n
vim.g.VM_mouse_mappings = 1
end
user/keymap/tool.lua
local bind = require("keymap.bind")
local map_cu = bind.map_cu
return {
["n|<C-d>"] = map_cu("Find Under"):with_noremap(),
["n|<C-d>"] = map_cu("Find Subword Under"):with_noremap(),
}
user/keymap/tool.lua
local bind = require("keymap.bind")
local map_cu = bind.map_cu
return {
["n|<C-d>"] = map_cu("Find Under"):with_noremap(),
- ["n|<C-d>"] = map_cu("Find Subword Under"):with_noremap(),
+ ["v|<C-d>"] = map_cu("Find Subword Under"):with_noremap(),
}
Still not working. After modification, <C-d>
will jump to the last line of the file, and the shortcut key for visual-multi is still <C-n>
.
r u using <C-d>
under visual mode?
oh wait, why do u use "Find Under" directly in the keymaps directly, that should be a function.
u should use following command instead: https://github.com/mg979/vim-visual-multi/blob/e2ff111f123da6cf97f95b96b10eb95854f953c9/doc/vm-ex-commands.txt#L8-L21
I think the key code should be the following part? https://github.com/mg979/vim-visual-multi/blob/e2ff111f123da6cf97f95b96b10eb95854f953c9/doc/vm-mappings.txt#L23-L29
So should I change the code to the following style?(But it still doesn't work)
user\keymap\tool.lua
local bind = require("keymap.bind")
local map_cu = bind.map_cu
return function()
vim.g.VM_maps["Find Under"] = "<C-d>" -- replace C-n
vim.g.VM_maps["Find Subword Under"] = "<C-d>" -- replace visual C-n
vim.g.VM_mouse_mappings = 1
end
I just want to change visual-multi's default shortcut key
Solution tested on my machine:
lua/user/plugins/editor.lua
local editor = {}
editor["mg979/vim-visual-multi"] = {
lazy = true,
event = { "CursorHold", "CursorHoldI" },
init = require("configs.editor.visual-multi"),
}
return editor
lua/user/configs/editor/visual-multi.lua
return function()
vim.g.VM_default_mappings = 0
vim.g.VM_maps = {
["Find Under"] = "<C-x>",
["Find Subword Under"] = "<C-x>",
}
vim.g.VM_mouse_mappings = 1
end
Not recommend register this map with <C-d>
which is usually used to pagedown and it has conflicts with neoscroll
.
If you want to set it in nvimdots
style, you can set it in this way:
lua/user/keymap/editor.lua
local bind = require("keymap.bind")
local map_cmd = bind.map_cmd
return {
["nv|<C-x>"] = map_cmd("<Plug>(VM-Find-Under)"):with_silent():with_noremap(),
}
In fact, seems all of vimscript-written plugins should use init
rather than config
to configure, we should correct current config.
In fact, seems all of vimscript-written plugins should use
init
rather thanconfig
to configure.
Yes, you are right. thanks for your help.
And I thought it would be more helpful to provide some content on vim plugin writing in the wiki?
And I thought it would be more helpful to provide some content on vim plugin writing in the wiki?
Done.
Version confirmation
Following prerequisites
Neovim version
NVIM v0.9.5
Branch info
main (Default/Latest)
Minimal (user) folder structure required to reproduce the issue
Minimal config with steps on how to reproduce the issue
I use the vim-visual-multi plugin and originally I filled in the configuration file as instructed in #901 (shown below)
user/plugins/visual-multi.lua
user/configs/visual-multi/viusal-multi.lua
However, after the recent update to v3.6.0, the configuration was found to be invalid. Then I looked at #1189 and the wiki link there. I changed the configuration to the following code:
user/plugins/visual-multi.lua
user/configs/visual-multi/visual-multi.lua
user/keymap/tool.lua
But this still doesn't seem to work, I think maybe it's the configuration code of the vim plugin that is different, but I don't know how I should modify my configuration.
Expected behavior
I can use
<C-d>
for word selection normallyAdditional information
No response