Thank you very much, i got it.
> flyfish wrote:
>> i write a simple keymap for commenting C file,
>> map C 0i/*<C-Esc>A*/<C-Esc>j
>> now i want to use the command like 12C to comment a block, however, it
>> not follow my mind, it does not comment one line then go down comment the
>> next line, it only give a lot of /* in the first line and make mistake,
>> to implement what i want?
>> Thank you very much.
> The way you do it, the 12 in 12C is simply prepended to the mapping,
> it to 120i/*<Esc> etc., i.e., adding /* ten times the count (120 times
> then */ once at the end of the line.
> Method I: Put your command in a register, let's say "q, and invoke that
> register with a count:
> :let @q = "0i/*\eA*/\ej"
> :let @q = "i\<Home>/*\<End>*/\<Down>\e"
> and in either case
> :map C @q
> Method II: Use a Visual-mode mapping:
> :vmap <F2> <Esc>:'<-1put ='/* '<CR>:'>put =' */'<CR>
> :vmap <F2> <Esc>:'<-1put ='#if 0'<CR>:'>put ='#endif'<CR>
> I recommend the last of the above, which will (if I didn't goof) add "#if
> above your (linewise) visual area and "#endif" below it, so than any /* */
> inside the block won't disturb the compilation.
> (I'm not sure what you use Ctrl-Esc for: I have no help for i_CTRL-Esc and
> my system, the Ctrl-Esc key is preempted by the window manager so that
> never sees it.)
> Best regards,
> "The society which scorns excellence in plumbing as a humble activity
> and tolerates shoddiness in philosophy because it is an exalted
> activity will have neither good plumbing nor good philosophy ...
> neither its pipes nor its theories will hold water."
View this message in context: http://www.nabble.com/what-is-wrong-with-my-keymap-for-commenting-a-block-tf3506043.html#a9800173
Sent from the Vim - General mailing list archive at Nabble.com.