Closed ghost closed 6 years ago
Basically if you press ctrl-d on a word, in selects the other words visually and when press c changing them at the same time, like refactoring or in multiple lines. More data at https://github.com/terryma/vim-multiple-cursors
So would the desired workflow be something like this?
X
to mark the multiple selections for an exchangeX
to invoke the swap of all occurrences of the first word with all occurrences of the second wordSounds pretty interesting and useful. I don't want to get your hopes up right now, as there's a lot more I need to know before I can judge whether this is feasible. My gut feeling right now is that it will be too complicated to support, and building a one-off specialized solution is probably a better bet.
I can think of a way to achieve this result with a different workflow using another plugin. Abolish.vim provides a :Subvert
command (can be shortened to :S
) which can help to do a pairwise swap of words. For example, you could use this:
:%S/{foo,bar}/{bar,foo}/gc
That will replace all foo
s with bar
and all bar
s with foo
(the c
flag makes it ask for confirmation at each occurrence). It's admittedly not as easy as the workflow you're proposing, but it could fill the void for now.
Some things I need to consider:
To support this, I think exchange.vim would need to have a way to let the user specify whether the operation is to mark an operand for exchanging or perform the actual exchange. Right now, it uses the same operator for both.
Actually yes, but multiple-cursors is working in hybrid-X mode. I stopped to use vim-multiple-cursors and i started to use vim-visual-multi. (mg979/vim-visual-multi). Actually its much more improved, also it can uses default visual mode mappings that means it can run every map. So after pressing
I'll request mg979 to add support for this plugin because understanding of visual multi plugin should be hard. For him much easier.
I don't know anything about the multiple-cursors plugin (aside from a high-level understanding of what it does). Can you describe the workflow that you're interested in?