BVI

Quick Tutorial: Find and replace


The :s (substitute) command behaves a little bit different to that of vi. If you type a command like this in vi   :s/XXXX/UU/ then the four XXXX's are replaced by two UU's. This means, the file size decreases and all characters after the replacement are moved to another position in the file. Since bvi does not move characters, only two XX's are replaced by two UU's and the third and fourth X still remains in the file.
Another example:

:0,500s/Taste\0/Key\0/RETURN

This command replaces within the first 500 bytes of a file the 0 - terminated ASCII string "Taste" with the 0 - terminated string "Key". After the substitution you will find a character sequence "Key\0e\0" in the file.
CAUTION: If the replace string is longer than the find string, additional bytes are overwritten!
This behaviour will not be changed by setting the :set memmove option!

Of course you can do also binary substitutions, similar to the search command. The ability of remembering patterns like \(pattern\) is currently not implemented.

Back to the top
Page updated: August 1st, 2025 by Gerhard Bürgmann, Purkersdorf/Austria