vi replace character code example Example 1: vim replace command :%s/foo/bar/g Example 2: global find and replace vi :%s/search_string/replacement_string/g