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.
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 RETURNThis 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.
or
:g\hex_pattern\p RETURN
Other forms of the global search command are line oriented, therefore not useful for binary files and not implemented, e.g.
:g/pattern/d Delete all lines containing pattern :g/pattern/y Yank all lines containing pattern :g!/pattern/p Print 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"