I\'d like to run a macro on every line in a selection, rather than totalling up the number of lines in my head. For instance, I might write a macro to transform:
You can add the function below to your ~/.vimrc
or simply copy it on your browser and running :@+
fun! RunMacroOverSelection(macroname)
execute "'<,'>normal @". a:macroname
endfun
com -nargs=1 Rover :call RunMacroOverSelection()
nnoremap r :Rover
The advantage is that you can apply any macro on the visual selection. You need to give the macro letter as argument, like:
:Rover a