=r.text_field :first_name
.control-group
=r.label :middle_name, "Middle Name", class: "control-label"
.controls
=r.text_field :first_name
.control-group
=r.label :middle_name, "Middle Name", class: "control-label"
:%s/\(^\s\+\)\(.*_field.*\)/\1\.controls\r\1 \2/g
Note: parenthesis in search regex have to be backwhacked in vim (
becomes \(
.
:%s/
this starts the search command :P\(^\s\+\)
this finds the whitespace at the beginning of each line\(.*_field.*\)
this finds strings that have "_field" in them\1\.controls\r\1 \2
the replace command with backreferences FTW