Vim Macro - Newbie here
by Myphre from LinuxQuestions.org on (#4VKEC)
Hi,
I need to edit some HTML pages and i want to create a macro in vim to make that. But i cant make properly the macro. Im lost in how to make the commands and make the macro work.
What I need is to:
(1) Locate and erase the "<";
(2) advanced one word;
(3) put "(" ;
(4) go to the next ">" and substitute this for ")";
(5) go to the next line
The commands i have seen that i can use are:
:s/<// "search for "<" and erase him
w "go to the next word
press i "enter in edition mode
insert "(" "insert the "("
press ESC " exit edition mode
:s/>/)/ " go to the next ">" and substitute this for an ")"
j "go to the next line
I have tried to just start the macro and put those commands but i receive the error " E465: :winsize requires two number arguments" and cant figure out what is happening.
I need too erase all the things that are between the "</ >", including the "</ >".
I was seeing that i can use vim scripts to make an if condition but i dont know either how to make and run the script.
Example:
Original code:
Code:
<a href="index.html" class="col-3">
<div class="verticalCenter">
<img id="logo" src="logo.webp">
</div>
</a>What I need to make:
Code:
a (href="index.html" class="col-3")
div (class="verticalCenter")
img (id="logo" src="logo.webp")thanks for the help


I need to edit some HTML pages and i want to create a macro in vim to make that. But i cant make properly the macro. Im lost in how to make the commands and make the macro work.
What I need is to:
(1) Locate and erase the "<";
(2) advanced one word;
(3) put "(" ;
(4) go to the next ">" and substitute this for ")";
(5) go to the next line
The commands i have seen that i can use are:
:s/<// "search for "<" and erase him
w "go to the next word
press i "enter in edition mode
insert "(" "insert the "("
press ESC " exit edition mode
:s/>/)/ " go to the next ">" and substitute this for an ")"
j "go to the next line
I have tried to just start the macro and put those commands but i receive the error " E465: :winsize requires two number arguments" and cant figure out what is happening.
I need too erase all the things that are between the "</ >", including the "</ >".
I was seeing that i can use vim scripts to make an if condition but i dont know either how to make and run the script.
Example:
Original code:
Code:
<a href="index.html" class="col-3">
<div class="verticalCenter">
<img id="logo" src="logo.webp">
</div>
</a>What I need to make:
Code:
a (href="index.html" class="col-3")
div (class="verticalCenter")
img (id="logo" src="logo.webp")thanks for the help