DEV Community

loading...

Discussion on: How To Search And Replace String Across Multiple Files in Vim

Collapse
bgturner profile image
Benjamin Turner

Vim's regex can do this with a newline character. So having a buffer like:

one
two
three

This will hit the "one two"

:%s/one\ntwo/replaced/

In some cases, depending on the line endings, you might need to include the carriage return: \r

I almost never get the search string right the first time, so using the highlight search and incremental search settings is really helpful.

:set hls incsearch

All this is super powerful, but I'll leave it to you to determine if it's sensible. :)

Thread Thread
epse profile image
Stef Pletinck

Oh yeah that's perfectly sensible and something I knew about, I was more talking about the sed approach