g flag in :s useless in vim
Some time back there was a post on vim_use list about the “/g” flag for the search and replace functionality of the vim. And the response of “Tim Chase” on the same was very elaborate and interesting. I always knew that “/g” is only for replacing multiple occurrences on the same line, but here are few things that I did not know.
:0/this/s//that
This one will only replace the first occurrence of this in the whole file.
:-/this/s//that
This one will replace the first occurrence of this in the file from current cursor position including the current line.
And finally here is the link to the post.
Related articles
- debug call function() to debug a function in vim (amit-agarwal.co.in)
- The best way to learn anything in Vim is by accident (stackoverflow.com)
- Get Started With the Vim Text Editor (pcworld.com)