A new feature of version 1.3.0 is the Partial File Read.
If you want to edit a file, you have not to read the file into
memory but only the part you want to edit. You can write back this part
into the file after editing.
Example:
You have to change only some bytes of the header of a graphic file
(e.g. a color). Graphic files can be very large. With the -s
option you can load only the first kilobyte of the file:
bvi -s 1000 large.gifIn this case of course you cannot insert or delete bytes of the file. The editor is set to the no memmove mode. You can write back only as much bytes as you read before. If you add or delete bytes even though, the extra bytes will be ignored or garbage will be written to the file.
It is also possible to start not at the begin of the file, but at a certain address. To do this you have to use the option -b. You can read the file from this starting point until the end of the file or you can use the -s option to specify a size or the -e option to specify an end address.
If you read the file not from the start an offset will be set to display the correct address at the left side of the screen. If you change this offset with the :set offset=nnnn command, this has no effect to the write back operation. The edited part of the file will always be written back at the same position, where it was read.
In the Linux /proc directory there are files which are listed with length 0 in a directory listing. But in reality they have a content. You can read this files, if you use the -s option and guess a size. This size should be a little bit larger than the size you expect.
The same guidlines can be used, if you load a block device, e.g. a floppy disk.
bvi -s 1450k /dev/fd0After reading the device, you get a message with the value of the real read bytes at the bottom of the screen:
"/dev/fd0" range 0-1474559Note that the size value will be used to allocate memory before reading the file. Therefore do not choose a too large size.
WARNING:
Do not use bvi at mounted disk devices!
Do not edit disk devices, if you don't know exactly what you change!
You may make your disk unreadable by editing it!!
If you used the ZZ or :w command, this part of the file will be
written back into the original file.
Back to the top