Wednesday, April 11, 2007

vi replace with confirmation and replace with regex group

Search from every line, replace confirmation (with [y]es)
:%s/search_string/replace_string/gc

Replace with regex group:
:%s/<img alt="\(.\+\)"\ssrc=.\+/\1/gc

Vi simple tutorial

Some examples:
You have [admin, admin1, user3], and you would like to change it to ['admin','admin1','user3']; here your are:%s\(\w\+\)/'\1'/gc

No comments: