I've written some customizations in my
.vimrc that I would like to further improve and refine.
In particular, for some key combinations, I'm doing text substitutions, like this:
vmap <C-S-w> :s/\%V.*\%V./Foo & Bar<Enter>:noh<Enter>
It replaces whatever has been marked with "Foo Bar". This works great.
However, I would like to extend this for the macro to be able to distinguish if the selection was made in regular visual mode ("v") or in visual line mode ("V").
Let's say on visual mode I want the above substitution but on visual line mode I want "Fooline & Barline".
I believe the answer lies within a vim function, but I cannot figure out how to approach this.
How to determine the current selection state and how to execute a substitution from a function?