I find that if you enter a numeric prefix prior to executing an ex command, the convention that it applies is to set up the command to prep an operation across a line range. It is explained in the documentation,
A NUMBER OF LINES
When you know how many lines you want to change, you can type the number and then ":". For example, when you type "5:", you will get:
Now you can type the command you want to use. It will use the range "." (current line) until ".+4" (four lines down). Thus it spans five lines.
Now what I am dealing with is a custom function of mine, this one:
function! MyAmazingEnhancedDot() if v:hlsearch == 1 :normal! .n else :normal! .j endif endfun
This is just a way to streamline repetitive tasks that include repeating an operation on a range of lines or over a series of search matches.
This function is bound to a hotkey. Such as Alt+. or whatever.
My aim is to be able to do something very powerful: I should be able to type
/varName<CR>ciwnew-var<ESC>n9<Alt+.> to achieve renaming 10 instances of
What actually happens if I do this is that it does not perform the renaming and the 9 lines are manipulated with my
.-saved edit operation from column 0.
I can only assume that Vim is interpreting my keystrokes thus:
:.,.+8 normal! .n.
On the glass-half-full side, the
:normal! .j case of the bind actually works, because the
j motion having no effect is of no consequence in this situation. (I still need the
j to make it work in a non-numeric-prefixed interactive use case).
So my question is how can I override the line-expansion behavior that Vim applies to my bind? What would be fantastic is if I can read in the numeric prefix as an argument or something like that.