map not working

G

googler

I am trying to create map for the operation I am going to explain. I
have some code like this:

`ifdef FUNCTIONAL
blah1
blah2
blah3
`else
blah4
blah5
blah6
`endif

I want to change it to:

//`ifdef FUNCTIONAL
// blah1
// blah2
// blah3
//`else
blah4
blah5
blah6
//`endif

I define my map as follows:
:map v /`ifdef[CTRL-V][ENTER]ma/`else[CTRL-V][ENTER]mb'a:.,'bs/^/\/\//
[CTRL-V][ENTER]/`endif[CTRL-V][ENTER]I//[CTRL-V][ESC][ENTER]

the above can be broken down into the following steps:
(1) /`ifdef[CTRL-V][ENTER] => search for `ifdef
(2) ma => mark the line as a
(3) /`else[CTRL-V][ENTER] => search for `else
(4) mb => mark the line as b
(5) 'a => go back to line marked as a
(6) :.,'bs/^/\/\//[CTRL-V][ENTER] => add // at the start of lines
from a to b
(7) /`endif[CTRL-V][ENTER] => search for `endif
(8) I//[CTRL-V][ESC] => add // to the start of this line

When I try to execute this sequence by placing the cursor just above
from where the block starts and pressing v, I do not get the desired
change. Instead it shows the message:
E488: Trailing characters

However, if I execute the commands manually one after the other, it
works fine. Please point out if you can see the error. Thank you.
 
G

googler

I am trying to create map for the operation I am going to explain. I
have some code like this:

Extermely sorry.. I posted in the wrong group. My apologies.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top