On Monday, July 16, 2012 11:02:15 AM UTC-5, FaQ wrote:
> Hello. I've been trying to figure out this for some time now, and couldn't find a solution.
>
> I have this mapping:
>
> nmap <silent> -c :<C-U>set opfunc=Add_comment_operator<CR>g@
>
> Below you'll find the Add_comment_operator() code, but I think it's not really relevant. This mapping allows me to do things like -ciw to comment the word under the cursor, or -ca{ to comment the block the cursor is in.
>
> Now, I would like it also to be able to type 4-c and comment four lines of code (the current one and three below). I don't know how to do this. I tried checking if there is a count querying the v:count variable, but then if I find out there isn't, the :normal g@ command doesn't do what I expect (it doesn't executes &opfunc after the motion).
In what way did you check the v:count variable? It should work. Also v:count1 should work, if you like that one better.
In this situation, I'd probably use an <expr> mapping. The mapping should call a function that either sets the opfunc option and returns g@ (without a count, because the count still applies), OR which returns your current map string, with the desired count to g@ inserted just prior to where g@ occurs in the current string.
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
No comments:
Post a Comment