I want to match a pattern, replace part of the pattern, and use a variable within the pattern as part of the replacement string.
Is this correct?
/s/^((\\s
I presume you want to replace it in vi
Replace all occurrences
:s/^\(\s\+\)private function __construct()/\1def __init__/g
Replace first
:s/^\(\s\+\)private function __construct()/\1def __init__/
Few suggestions to your pattern
/ is used in vi for search , use :( ) in vi\i where i is xth capture group like \1 \2 to back reference grouped patterns in replacement\s can not be used in replacement text use ' ' instead/g if you want to replace all occurrenceshttp://vimregex.com should help you get started.