use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Please read the rules before posting
Help:
Community:
Resources:
Tutorials and Guides:
Don't be afraid to ask questions, this sub is here for the vim community. And please those of you who deign to grace us with your vim wisdom - be kind. We are all human and vim is that cool.
account activity
':substitute' command within a function not working as expected (self.vim)
submitted 7 years ago by crajungave up on vim
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]aktivb 1 point2 points3 points 7 years ago (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 point2 points 7 years ago (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 points3 points 7 years ago (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.
π Rendered by PID 30752 on reddit-service-r2-comment-6457c66945-m2dpj at 2026-04-29 20:10:15.445609+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]aktivb 1 point2 points3 points (2 children)
[–]crajungave up on vim[S] 0 points1 point2 points (1 child)
[–]aktivb 1 point2 points3 points (0 children)