Thank you very much, i got it. A.J.Mechelynck wrote: > > flyfish wrote: >> Hi, >> >> 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 >> does >> 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, >> how >> to implement what i want? >> >> Thank you very much. > > The way you do it, the 12 in 12C is simply prepended to the mapping, > changing > it to 120i/*<Esc> etc., i.e., adding /* ten times the count (120 times > here), > 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" > or > :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> > or > :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 > 0" > 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 > on > my system, the Ctrl-Esc key is preempted by the window manager so that > gvim > never sees it.) > > > Best regards, > Tony. > -- > "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.