g flag in :s useless in vim
2011-11-05
139 words
1 min read
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)
Related Articles:
- 2011/04/16 vim autocomplete – automagically without tab.
- 2010/10/02 [Solved] Abbreviations not working in vim
- 2011/09/04 debug call function() to debug a function in vim
- 2011/03/16 what is vim in 6Kb..
- 2011/03/09 All in one solution for all the scripts of vim from vim.org
Authored By Amit Agarwal
Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.