BVI

Search Commands


Additional to the well known / and ? for searching ASCII strings there are two new commands for searching binary strings. These are the keys \ and #.

In the ASCII search commands / and ? you can use \n, \r, \t and \0. You can also use regular expressions. Do not use ^ and $, because there are no lines in a binary file. Type /foo\0 RETURN to search for the null terminated string foo in the file.

In the Hex section you can search for a sequence of bytes in hexadecimal notation, e.g. \01 AF 12 RETURN, which is the same as \01AF12 RETURN. You can also use regular expressions and quoted ASCII strings. Inside of the quotes no character is treated as a special character!
Example:   \01 [^AF DE] "foo" 00 RETURN
This means: Search for a string beginning with 01, the second character must not be a hex AF or DE, followed by the ASCII characters foo, terminated with a binary zero.

Global Search

There is also a global search option available, but only with the print option.
Example:
:g/text_pattern/p RETURN
or
:g\hex_pattern\p RETURN
This commands are displaying all found patterns, one per screen line. Of course you can limit the search to a certain part of the file by specifying the starting and ending address.
Other forms of the global search command are line oriented, therefore not useful for binary files and not implemented, e.g.
:g/pattern/dDelete all lines containing pattern
:g/pattern/yYank all lines containing pattern
:g!/pattern/pPrint all lines not containing pattern

 

Back to the top
Page updated: October 12th 2019 by Gerhard Bürgmann, Purkersdorf/Austria
Have a look at "Lighting Lifts"