Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

I'd think something like:

:%s/word1\(.*\)word2$/word3\1word4/

Over each line in the whole file, search for word 1 and word 2 (which is at the end of the file), separated by arbitrary non-newline characters, and change them to word3 and word4.



The Emacs equivalent would be

    M-x replace-regexp word1\(.*\)word2$ RET word3\1word4 RET
Assuming you have `replace-regexp` bound to a key, it's practically the same. Works on the whole buffer (by default), or the region (if selected).




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: