BVI: Editing Files

Home Quick Tutorial Editing Files Search Commands Bit-wise Operations Find and Replace Yank and Put Settings Partial File Read Download Installation Command Overview bmore Deutsche Beschreibung |  |
Quick tutorial Editing Files |
> Inserting or deleting bytes can be dangerous on some kind of files, because binary files are mostly executables, database files or maybe graphic files. So you must not shift the remaining bytes to another address. Therefor commands for inserting or deleting bytes are disabled by default. You can use the r command to change a single byte, or the R command to replace multiple characters. You can use a numeric prefix for both commands. You can add characters at the end of the file using the A command. If you start with an empty file, you can create a binary file from scratch. If the cursor is in the ASCII section of the screen and you type `100Ax`ESC, you create a file which contents 100 x'es. The D command can be used to truncate a file at a certain position. Since there are no lines in a binary file, the D command deletes to end of file. If you have to edit a binary file where it does not matter to move bytes to a different address, you can enable the insert and delete commands by typing :set memmove. Now you are able to use the i command for inserting bytes, the x or X command to delete the byte over or before the cursor and those types of d commands, which does not rely on text lines (e.g. dSPACE, df`C`, d/`xyz`, d$, d'a, d`n`G). All edits can be undone by pressing the u key. #### Using ex (colon) commands The edit commands of the ex editor are usually not available in standard vi implementations (`:i[nsert], :a[ppend]` and `:c[hange]`). In bvi they are available with extended options. There are five modifiers `a[scii], b[inary], d[ecimal], h[exadecimal]` and `o[ctal]` (ascii is default). Therefor you can insert, append or change data in all five representations. Example: you would like to append a file with data available in decimal representation:
>     :a d
>     0 12 3 128 255 17 0 0 255 255
>     23 24 25 128 6 6 6
>     .
A line with only a period (.) in it will terminate the command. You must not type values greater than a byte value (255 decimal, FF hex). This causes an abandon of the command. Pressing the RETURN key does not insert a newline - character into the file. If you use :i a (insert ascii) you can use the special characters \n, \r, \t and \0. An additional advantage is, that all typed bytes are inserted into the file at once. If you insert characters in vi - mode, for every byte typed, the whole remaining file has to be moved one position backwards. Back to the top Last update: June 1st 2000 by Gerhard Bürgmann, Purkersdorf/Austria