Q:

vim replace between lines

# Basic syntax:
:<start_number>,<end_number>s/search_text/replacement_text/g

# Example usage:
# Say you have a file with the following text and only want to change 
# mispeled to misspelled on lines 2 and 3:
1. I mispeled a word on this line
2. I also mispeled a word on this line
3. Apparently I cant type mispeled properly

:2,3s/mispeled/misspelled/g # This would change the words on line 2 and 3
2
# Replace all instances of foo with bar
:%s/foo/bar/g

# Replace all instances of foo in lines 6 to 10 inclusive with bar
:6,10s/foo/bar/g
0
:5,12s/foo/bar/g
0

New to Communities?

Join the community