How can I change all occurrences of xxxxx to yyyyy within vi? To change only the first occurrence of something (per line) in the file, do this: :%s/hsots/hosts/ To change every occurrence on each line of the file: :%s/hsots/hosts/g To change all occurrences of hsots to hosts on lines 3-5, do: :3,5s/hsots/hosts/g Yeah, yeah, you get the idea....