BVI(1)
๐ BVI โ the manual, but make it make sense ๐
okay so bestie. sit down. we're talking about bvi and bview, and ngl this page is a whole vibe. it's BVI(1), User Commands, and it's giving "hex editor that actually loves you". let's get into it ๐ซถ
โจ NAME โจ
bvi, bview โ visual editor for binary files. that's it, that's the whole pitch, slay ๐
๐ธ VERSION ๐ธ
bvi-1.5.0 โ periodt, that's the version, don't @ me โจ
๐ฆ SYNOPSIS ๐ฆ
bvi [-R] [-c cmd] [-f script] [-s skip] [-e end] [-n length] file...
bview [-R] [-c cmd] [-f script] [-s skip] [-e end] [-n length] file...
literally the same flags for both, they're twins, iconic ๐
๐ OPTIONS ๐
okay so here's where it gets good. every single one of these matters, so pay attention bestie:
file...โ a list of filenames. the first one becomes the current file and gets read into the buffer, and the cursor parks itself on the first line of the buffer. wanna hop to the other files? use the:nextcommand, easy ๐-Rโ "Readonly". the readonly flag gets set for all the files, so you can't accidentally overwrite stuff with a write command. protective king behavior ๐ก๏ธ-s skipโ makesbviload a file not from the start but from offsetskip. so it skipsskipoffset bytes from the beginning of the input. by default,offsetis read as a decimal number. with a leading0xor0Xit's hexadecimal, otherwise with a leading0it's octal. and if you appendb,k, ormtooffset, it gets interpreted as a multiple of 512, 1024, or 1048576 respectively. math girlies rise up ๐ง-e endโ makesbviload a file not tillendbut till addressend. yeah. exactly what it says ๐ธ-n lengthโ makesbvinot load the complete file but onlylengthbytes. lil snack instead of the whole meal ๐-c cmdโcmdgets executed after the first file has been read. ifcmdcontains spaces it must be wrapped in double quotes (this depends on the shell you're using, iykyk). so like, quote it. please. ๐-f scriptโ this one is a whole moment. it gives you a way to collect a series ofex(colon) commands into a script file, then use that file to edit other files. and since there is no binary stream editor "bsed", you can use this option to make several global changes in a binary file. no bsed? no problem, we improvise ๐
๐ DESCRIPTION ๐
Bvi stands for "Binary VIsual editor". yes. it's a screen oriented editor for binary files, and its command set is based on that of the vi(1) text editor. but here's the plot twist โ since bvi is a binary editor, it does not have the concept of "lines". all end-of-lines (EOLs) are simply bytes. therefore bvi's commands are different from vi's commands for all the line-oriented commands (see below). no lines, no drama, just bytes ๐
๐ฅ COMPARISON ๐ฅ
the main differences between Vi and Bvi are, bestie:
the screen is divided into three sections (or panes): the byte offset (extreme left), the hex pane (middle), and an ascii pane (right) which shows as printable characters those bytes that are in the hex pane. on an 80 column terminal there will be sixteen hex values and their ASCII values on each screen line. and note that (as one would expect) the first byte has the offset '0' (zero). zero. not one. we start at zero here ๐ซถ
you can toggle between the hex and ascii windows with the tab key (TAB). and toggling between these two windows does not change the current position (offset) within the file. your place is safe, periodt โจ
No "lines" concept: files are treated as one long stream of bytes. the characters "newline" and "carriage return" are not special, id est they never mark the end of lines. therefore the lines on the screen do not represent lines in the usual way. data is broken across screen lines arbitrarily. as a consequence there are no commands in bvi from ex or vi that are based on line numbers, eg dd, yy, C, S, o, O. this also changes the meaning of "range" before the :write command to a byte offset, ie the command :100,200w foo writes all bytes (not lines) from offset 100 to offset 200 to the file foo. read that again. bytes. not lines. ๐ญ
No "text objects": there are also no text-specific arrangements like words, paragraphs, sentences, sections and so on. gone. not here. we don't do that ๐
Extended "ruler": the bottom line of the screen shows the current address (byte offset) and the current character in these notations:
octal, hexadecimal, decimal and ascii.
Search patterns: all search commands understand these special characters:
. any character
[] set of characters
* zero or more occurrences of previous char or set
but as there is no concept of lines you cannot use the standard symbols ("anchors") for "begin-of-line" (^) and "end-of-line" ($). searching for the start/end of lines must be done explicitly by adding these special characters to your search pattern using these meta sequences:
\n newline
\r return
\t tab
\0 binary zero
Additional search commands: similar to the text search commands there are additional hex-search functions \ and # which allow one to search for any byte value. example: "\62 76 69" will search for the string "bvi". spaces between hex value are optional, so searching for "6775636B6573" will find "guckes". obsessed with this ngl ๐
changing the length of data (insertion, deletion) moves the data to other addresses. this is bad for many cases (eg. databases, program files) and is thus disabled by default. you can enable this commands by typing:
:set memmove
okay so now the BVI Modes, and there's three of them, main character energy for real:
๐ Command Mode (Normal Mode) ๐
input is treated as command. note that command mode is the default mode after startup and after escaping from input mode. use ESC (escape) to cancel a partial (uncompleted) command. unfinished business? cancel it, queen ๐
๐ธ Input Mode ๐ธ
input is treated as replacement of current characters or (after the end of the file) is appended to the current file. this mode is entered from command mode by typing one of i, I, A, r, or R. you can enter the characters from the keyboard (in the ASCII window) or hexadecimal values (in the HEX window). type TAB to switch between these two windows. type ESC to finish the current input and return to command mode. type CTRL-C to cancel current command abnormally. know your exits bestie ๐ช
๐ฆ Command line mode (Last Line Mode or : mode) ๐ฆ
similar to vi, this mode is entered by typing one of the characters : / ? \ # ! โ the command is terminated and executed by typing a carriage return; to cancel a partially typed command, type ESC to cancel the current command and return to command mode. so many ways in, one clean way out โจ
๐ฟ ENVIRONMENT ๐ฟ
the editor recognizes the environment variable BVIINIT as a command (or list of commands) to run when it starts up. if this variable is undefined, the editor checks for startup commands in the file ~/.bvirc, which you must own. however, if there is a .bvirc owned by you in the current directory, the editor takes its startup commands from this file โ overriding both the file in your home directory and the environment variable. current directory wins, home dir and env var cry about it, that's just the rules ๐
๐ซ TERMINOLOGY ๐ซ
character names are abbreviated as follows:
CRโ010โ carriage return^Aโ001โ control-a^Hโ008โ control-h^Iโ009โ control-i โ aka TAB^Uโ021โ control-u^Zโ026โ control-zESCโ027โ escape โ aka ESCDELโ127โ deleteLEFTโ---โ left arrowRIGHTโ---โ right arrowDOWNโ---โ down arrowUPโ---โ up arrow
and that's where part 1 leaves us, bestie โ more is coming, don't go anywhere ๐
๐ COMMAND SUMMARY ๐
okay bestie, before we dive in โ peek at TERMINOLOGY for the rundown on all the key-name abbreviations used in the command descriptions below. iykyk ๐ซถ
๐ธ Abstract ๐ธ
Arrow keys move the cursor on the screen within the current window. that's it. that's the whole vibe.
โญ Sample commands โญ
:version show version info
<- v ^ -> arrow keys move the cursor
h j k l same as arrow keys
u undo previous change
ZZ exit bvi, saving changes
:q! quit, discarding changes
/text search for text
^U ^D scroll up or down
๐ข Counts before bvi commands ๐ข
Numbers may be typed as a prefix to some commands. They are interpreted in one of these ways, and which way depends on the command:
screen column โช
byte of file G
scroll amount ^D ^U
repeat effect most of the rest
๐ Interrupting, canceling ๐
ESCโ end insert or incomplete commandDELโ (delete or rubout) interrupts
๐ File manipulation ๐
ZZโ if file modified, write and exit; otherwise, exit:wโ write changed buffer to file:w!โ write changed buffer to file, overriding read-only (this is a "forced" write, no cap ๐ ):qโ quit when no changes have been made:q!โ quit and discard all changes:e fileโ edit file:e!โ re-read current file, discard all changes:e #โ edit the alternate file:e! #โ edit the alternate file, discard changes:w fileโ write current buffer to file:w! fileโ write current buffer to file overriding read-only (this "overwrites" the file):shโ run the command as set with option"shell", then return:!cmdโ run the commandcmdfrom"shell", then return:nโ edit next file in the argument list:fโ show current filename, modified flag, current byte offset, and percentage of current position within buffer^Gโ same as:f
โ๏ธ Additional edit commands โ๏ธ
You can insert/append/change bytes in ASCII/binary/decimal/hexadecimal or octal representation. You can enter several (screen) lines of input. A line with only a period (.) in it will terminate the command.
๐จ You must not type in values greater than a byte value. That causes an abandonment of the command. bye bye input, we hardly knew ye ๐ญ
Pressing the CR key does not insert a newline-character into the file. If you use ASCII mode you can use the special characters \n, \r, \t and \0.
:i aCR insert bytes (ASCII) at cursor position
:a bCR append bytes (Binary) at end of file
:c hCR change bytes (hexadecimal) at cursor position
๐งฎ Bit-level operations ๐งฎ
:and nโ bitwise 'and' operation with valuen:or nโ bitwise 'or' operation with valuen:xor nโ bitwise 'xor' operation with valuen:negโ two's complement:notโ logical negation:sl iโ shift each byteibits to the left:sr iโ shift each byteibits to the right:rl iโ rotate each byteibits to the left:rr iโ rotate each byteibits to the right
๐ Command mode addresses ๐
:w foo write current buffer to a file
named "foo"
:5,10w foo copy byte 5 through 100 into as
file named foo
:.,.+20w foo copy the current byte and the next
20 bytes to foo
:^,'aw foo write all bytes from the beginning
through marker 'a'
:/pat/,$ foo search pattern pat and and copy
through end of file
๐งญ Positioning within file ๐งญ
^Bโ backward screen^Fโ forward screen^Dโ scroll down half screen^Uโ scroll up half screennGโ go to the specified character (end default), wherenis a decimal address/patโ next line matchingpat?patโ previous line matchingpat\hexโ jump to next occurrence of hex stringhex#hexโ jump to previous occurrence of hex stringhexnโ repeat last search commandNโ repeat last search command, but in opposite direction
๐ฅ๏ธ Adjusting the screen ๐ฅ๏ธ
^Lโ clear and redraw screenzCRโ redraw screen with current line at top of screenz-โ redraw screen with current line at bottom of screenz.โ redraw screen with current line at center of screen/pat/z-โ search for patternpatand then move currents line to bottom^Eโ scroll screen down 1 line^Yโ scroll screen up 1 line
๐ Marking and returning ๐
mxโ mark current position with lower-case letterx. Note: this command works for all lower-case letters'xโ move cursor to markxin ASCII section`xโ move cursor to markxin HEX section''โ move cursor to previous context in ASCII section``โ move cursor to previous context in HEX section
โฌ๏ธโฌ๏ธ Line positioning โฌ๏ธโฌ๏ธ
Hโ jump to first line on screen ("top")Lโ jump to last line on screen ("low")Mโ jump to middle line on screen ("middle")-โ jump onto previous line on screen+โ jump onto next line on screenCRโ same as+DOWNorjโ next line, same columnUPorkโ previous line, same column
๐ค Character positioning ๐ค
^โ first byte in HEX window$โ end of screen linelorRIGHTโ jump onto next byte (within current screen line)horLEFTโ jump onto previous byte (within current screen line)^Hโ same asLEFTspaceโ same asRIGHTfxโ find next occurrence of characterxFxโ find previous occurrence of characterxnโชโ jump onto nth byte/character within current line
๐งต Strings ๐งต
(works similar to the strings(1) command)
Note: "Words" are defined as strings of "nonprinting characters". slay ๐
eโ jump to next end of wordwโ jump to next begin of wordbโ jump to previous begin of wordWโ forward to next string delimited with a\0or\nBโ back to previous string delimited with a nonprinting char
๐ Corrections during insert ๐
^Hโ erase last character (backspace)eraseโ your erase character, same as^H(backspace)ESCโ ends insertion, back to command mode
๐ฆ Append and replace ๐ฆ
Aโ append at end of filerxโ replace current byte with char'x'Rโ enter replace mode; for all subsequent input, the current byte is overwritten with the next input character; leave replace mode withESC.
๐ฒ Miscellaneous Operations ๐ฒ
TABโ toggle between ASCII and HEX section
๐ Yank and Put ๐
3ySPACEโ yank 3 characterspโ insert contents of yank bufferoโ replace text with content of yank bufferPโ put back at end of file
โฉ๏ธ Undo, Redo โฉ๏ธ
uโ undo last change
Note: Only the last change can be undone. Therefore this commands toggles between the last and second-t-last state of the buffer. so it's a lil toggle situation, not a full time machine ๐ญ
โ๏ธ Setting Options โ๏ธ
With the :set command you can set options in bvi ๐
autowrite(default:noaw) โ Save current file, if modified, if you give a:n,:ror!commandcolumns(default:cm=16) โ on an 80 character wide terminalignorecase(default:noic) โ Ignores letter case in searchingmagic(default:nomagic) โ Makes.[*special in patternsmemmove(default:nomm) โ enables insert and delete commandsoffset(default:of=0) โ adds an offset to the displayed addressesreadonly(default:noro) โ If set, write fails unless you use!after commandreverse(default:nore) โ display otherwise-printable characters with their high bit set as reverse videoscroll(default:sc=1/2 window) โ Number of lines scrolled by^Uand^Dshowmode(default:mo) โ Displays statusline on bottom of the screenterse(default:noterse) โ Let you obtain shorter error messageswindow(default:window=screensize) โ Lines in window, can be reduced at slow terminalswordlength(default:wl=4) โ Length of an ASCII-string found byw,W,borBwrapscan(default:ws) โ Searches wrap around past the end of the fileunixstyle(default:nous) โ The representation of ascii characters below 32 is displayed in the statusline as shown inascii(7)if unset rather in DOS-style (^A)
๐ AUTHOR ๐
bvi was developed by Gerhard Buergmann, Vienna, Austria โ gerhard@puon.at
the literal icon who made all this happen ๐
๐ WWW ๐
- Bvi Homepage:
https://bvi.sourceforge.net/ - Vi Pages:
http://www.guckes.net/vi/clones.php3- (all about Vi and its clones)
๐ FILES ๐
$HOME/.bvirc editor startup file
./.bvirc editor startup file
๐ SEE ALSO ๐
bmore(1), vi(1), strings(1), ascii(5)
okay bestie that's the whole page ๐ this lil masterpiece is BVI Version 1.5.0 from the 3rd Berkeley Distribution, and it's filed under BVI(1) ๐ go forth and edit those bytes, you absolute main character ๐ซถโจ
๐ฆ where this page comes from
- alpine 3.24: bvi-doc 1.5.0-r0 ยท GPL-3.0-or-later
- fedora 43: bvi 1.5.0-1.fc43 ยท GPL-3.0-or-later
- fedora 44: bvi 1.5.0-3.fc44 ยท GPL-3.0-or-later
- nixos 26.05: bvi 1.5.0
- nixpkgs unstable: bvi 1.5.0
- ubuntu resolute: bvi 1.5.0-1 ยท GPL-3.0-or-later
- ubuntu stonking: bvi 1.5.0-1 ยท GPL-3.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms