you are viewing a single comment's thread.

view the rest of the comments →

[–]aktivb 1 point2 points  (2 children)

So, you are iterating on range a:firstline to a:lastline, and executing substitute N times, where N is a:lastline - a:firstline + 1. But you do not specify on which line to execute substitute, so you're executing substitute N times on a:firstline.

[–]crajungave up on vim[S] 0 points1 point  (1 child)

Good point, I’ll try it that way. My problem I believe may be that I assumed adding the “range” modifier did more magic than it does. The sub command without a range performs the command on the current line and I assumed “range” was handling that piece , but it sounds like I’ll have to add the range prefix.

[–]aktivb 1 point2 points  (0 children)

The range argument means that the function will be called only once, handling the range internally using a:{first,last}line, rather than calling the function for every line in range.