vimscript: how delete a variable number of lines
In a vimscript I need to repeatedly delete lines from the buffer, but the number of lines to delete will vary with each iteration of the loop.
:d is the only command I know of that will remove entire lines, but how can I use it with a variable specifying the number of lines to be deleted? |
You can do it with a loop, like this:
Code:
:let linesToRemove =3 |
Quote:
Code:
:normal ma |
Looks more elegant than a loop, definitely, but it may be not a good idea to change marks, especially when you deploy your script to other users. I thought about that and with a little reading in the Vim documentation I found this way to do it:
Code:
"Get the line number of the current cursor position |
All times are GMT -5. The time now is 12:13 AM. |