svermeulen / vim-subversive

Vim plugin providing operator motions to quickly replace text
MIT License
297 stars 4 forks source link

Problem with substituting over range #23

Open niomate opened 2 years ago

niomate commented 2 years ago

Hi, I have a small problem with the substitution. Whenever I want to substitute say all e's in a single word, it substitutes all e's in the line instead.

asciicast

Input was <leader>sliw

The problem also occurs with minimal config with only subversive installed.

Neovim version output:

NVIM v0.6.1
Build type: Release
LuaJIT 2.0.5
Compiled by builduser

Features: +acl +iconv +tui

Keymap config (lua):

vim.api.nvim_set_keymap("n", "ss", "<Plug>(SubversiveSubstituteLine)", {})
vim.api.nvim_set_keymap("n", "S", "<Plug>(SubversiveSubstituteToEndOfLine)", {})

vim.api.nvim_set_keymap("n", "<leader>s", "<Plug>(SubversiveSubstituteRange)", {})
vim.api.nvim_set_keymap("x", "<leader>s", "<Plug>(SubversiveSubstituteRange)", {})
vim.api.nvim_set_keymap("n", "<leader>ss", "<Plug>(SubversiveSubstituteWordRange)", {})
svermeulen commented 2 years ago

This is a valid issue, but I'm not sure how we'd go about implementing it. Under the hood, subversive generates an ex-mode command to perform the substitution, and as far as I know ex-mode ranges can only be specified as lines. You can see the ex-mode command that is generated for any substitution by enabling the subversivePromptWithActualCommand setting

niomate commented 2 years ago

Oh I thought this was just my installation acting up. I could have sworn that this was working for me before switching to lua for my configuration.