Vim substitute

Updated: 15 July 2023

Capture groups

Given the following

one foo one
one bar one

this substitution :s/one\(.*\)one/two\1two/ yields

two foo two
two bar two

Replace text with a new line

Given the following

phpdoc_separation, blank_line_before_statement, ordered_imports
class_attributes_separation, phpdoc_summary, phpdoc_separation

this substitution :s/, /\r/g yields

phpdoc_separation
blank_line_before_statement
ordered_imports
class_attributes_separation
phpdoc_summary
phpdoc_separation