I have a mapping like below to move the cursor to the first column of input/update (the red-circled) area in a table. And I can type w or ww to get to the 2nd/3rd column if needed.
noremap <s-F8> 0f\|ew
It goes to the anchor | first, to the end of the green number, and moves to next word (can be a dot, a number or an expression) in the table as below.

I wonder if I can use the count given in front of a normal-mode command to get to the 2nd or 3rd column directly, with a command 2<s-F8> or 3<s-F8>.
The following code doesn't work, though the @= helps separate the count from the 0 command.
noremap <s-F8> @='0f\|ew'<cr>
I studied the answer of Karkat in the post Mapping with v:count in vim and made this mapping:
noremap <expr> <s-F8> '0f\|e' . v:count1 . 'W'
But it doesn't move if a count is given. (It does move to column 1 if there is no count.)
What would be the correct way to use v:count1 in such a mapping?
Use the :execute STRING command to include the v:count1 in the string:
noremap <silent> <s-F8> :<c-u>exe 'norm 0f\|e' . v:count1 . 'W'<cr>
Note: The CTRL-U is used to remove the range that Vim may insert.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With