1HEXER(1)                    General Commands Manual                   HEXER(1)
2
3
4

NAME

6       hexer - binary file editor
7

SYNOPSIS

9       hexer [options] [file [...]]
10

DESCRIPTION

12       hexer  is  a  multi-buffer  editor  for viewing and manipulating binary
13       files.  It can't (shouldn't) be used for editing block devices, because
14       it  tries  to  load  the  whole  file into a buffer (it should work for
15       diskettes).  The most important features of hexer are:  multi  buffers,
16       multi  level undo, command line editing with completion, binary regular
17       expressions (see below).  The user interface is kept similar to vi,  so
18       if you know how to use vi, you'll get started easily.
19

OPTIONS

21       -R, --readonly
22
23       -v, --view
24           Edit files in read only mode.
25
26       -r, --recover filename
27           Recover the file filename after a crash. (not implemented)
28
29       -c, --command command
30           Start  the editing session by executing the editor command command.
31           If command contains spaces, it must be surrounded by double quotes.
32           It is possible to specify multiple commands on the command line:
33           hexer -c command1 -c command2 ...
34
35       -t, --tite
36           Turn off the usage of the termcap/terminfo ti/te sequence.
37
38       -h, --help
39           Display a short help message and exit.
40
41       -V, --version
42           Display program version information and exit.
43
44       -F, --features
45           List the features supported by the program and exit.
46
47       +command
48           This is equivalent to the -c option.
49
50       Note: The long options are not available on all systems.
51

CUSTOMIZING

53       The editor reads its startup commands from the file ~/.hexerrc (another
54       startup file may be specified by setting the environment variable  HEX‐
55       ERRC).   Empty  lines  and  lines starting with a `"'‐character (double
56       quote) are ignored.  It is not possible to have a command and a comment
57       in the same line.
58

EDITOR COMMANDS

60       As in vi, there are several editing modes:
61
62       Command Mode
63           Some  commands  in  Command  Mode  can take a numeric argument.  To
64           enter a numeric argument just type the (decimal) number.  The  num‐
65           ber  will  be  echoed at the bottom line of the screen as you type.
66           To enter an octal number, type a `0' as the first digit.  To  enter
67           a hexadecimal number, type `0x' (this is not a problem, because the
68           x-command with a zero counter wouldn't make sense anyway).  Some of
69           the  commands can take a visually selected area as an argument (see
70           subsection Visual Mode).
71
72           b      Move backwards to the beginning of a word.
73
74           e      Move to the end of a word.
75
76           G      If a numeric argument n is given, move the cursor  to  posi‐
77                  tion  n.   If  no argument is specified, set the position to
78                  the end of the buffer.  The first byte in the buffer  is  at
79                  position `0', so the command to move to the beginning of the
80                  buffer is `0G'.
81
82           Control-G
83                  Display the buffer name, size, status and the current  posi‐
84                  tion at the bottom line.
85
86           h j k l
87                  Move  the cursor.  The arrow keys work as well.  The numeric
88                  argument (if specified) determines the number rows  or  col‐
89                  umns  the  cursor  will move.  Different from vi: the cursor
90                  can be positioned behind the last byte in the buffer.
91
92           i      Enter Insert Mode (see below) at the current position of the
93                  point.   If  a  numeric  argument n is given, the typed text
94                  will be inserted n times.  Note: Moving  the  cursor  (using
95                  the arrow keys) will discard the numeric argument.
96
97           n      Move to the next match using the current RE.  This is equiv‐
98                  alent to typing `/', <Return>.
99
100           N      Move to the previous match using the current  RE.   This  is
101                  equivalent to typing `?', <Return>.
102
103           Control-O
104                  Paste  over.   Copy  the kill buffer to the current position
105                  overwriting the  contents  of  the  current  buffer.   If  a
106                  numeric  argument  n  is  given, the kill buffer is pasted n
107                  times.
108
109           p      Paste.  Insert the kill buffer at the current position.   If
110                  a  numeric  argument n is given, the kill buffer is pasted n
111                  times.
112
113           r      Replace a single byte using the Replace Mode.  If an area is
114                  selected, all bytes in the selected area are replaced.  If a
115                  numeric argument is given, the specified number of bytes  is
116                  replaced.
117
118           R      Enter  Replace Mode (see below).  If a numeric argument n is
119                  given, the replace command is repeated n times.  Note:  Mov‐
120                  ing  the  cursor  (using  the  arrow  keys) will discard the
121                  numeric argument.
122
123           Control-R
124                  Redo the last undo.
125
126           u      Undo the last change to the current buffer.
127
128           Whenever possible hexer creates a file name.hexer  in  the  current
129           directory (the swapfile) for each buffer visited (where name is the
130           name of the buffer).  All changes  made  to  the  buffer  name  are
131           stored  in  that  file,  so  it  is possible to undo (and redo) all
132           changes made to the buffer.  If the swapfile can't be created,  the
133           undo list is stored in the memory.
134
135           v      Enter Visual Mode (see below).  Visual selection of areas.
136
137           w      Move forward to the beginning of a word.
138
139           x      Delete  the  byte under the cursor.  If a numeric argument n
140                  is given, n bytes are deleted.  In Visual Mode, the selected
141                  area  is  deleted.  Note: The bytes deleted using the x-com‐
142                  mand are not copied to the kill buffer.
143
144           Control-X
145                  The same as the x-command, but the bytes deleted are  copied
146                  to the kill buffer.
147
148           y      Yank.   Yank the byte under the cursor into the kill buffer.
149                  If a numeric argument n is given, n bytes  are  yanked  into
150                  the  kill  buffer.   In  Visual  Mode,  the selected area is
151                  copied to the kill buffer.
152
153           zb     Place the cursor in the bottom line of the screen.
154
155           zt     Place the cursor in the top line of the screen.
156
157           zz     Place the cursor in the middle line of the screen.
158                  Note that the commands zb, zt and zz don't change the  posi‐
159                  tion  in  the  file - only the screen is scrolled (if neces‐
160                  sary).
161
162           :      Enter Exh Mode (see below).  The Exh Mode is similar to  the
163                  ex-mode  in vi, but not compatible.  If an area is selected,
164                  the bounds of the selection are copied to the command line.
165
166           /      Search forward through the buffer using a RE(regular expres‐
167                  sion).   If no RE is specified, the RE given in the previous
168                  /- or ?-command is reused.
169                  Note: The REs in hexer are a little bit different from regu‐
170                  lar expressions in vi (see section REGULAR EXPRESSIONS).
171
172           ?      Search reverse using a regular expression.
173
174           .      Repeat  the  last  change to the buffer at the current posi‐
175                  tion.  This means that if the  previous  command  deleted  n
176                  bytes  and  replaced  them  by  m other bytes (n or m may be
177                  zero), the .-command will do exactly the same at the current
178                  position in the file.
179
180           <      Shift the hex column left n bytes, where n is the (optional)
181                  numeric argument.  Note that the <-command only changes  the
182                  way  the  buffer  is displayed in the hex column, the buffer
183                  itself is kept unchanged.
184
185           >      Shift the hex column right n bytes.
186
187           Control-^
188                  Switch to the alternate buffer (see below).
189
190           %      Enter a calculator command (see section CALCULATOR).
191
192       Visual Mode
193           Select an area on the buffer.  You can enter  the  Visual  Mode  by
194           using  the  v-command  or  by  specifying an area in Exh Mode.  The
195           selection starts at the cursor position when  entering  the  Visual
196           Mode  and  ends  at the current cursor position.  You can leave the
197           Visual Mode without performing a command on the  selected  area  by
198           pressing  v  or  Escape.  To perform a command on the selected area
199           simply enter the command as if you where in Command Mode.  Commands
200           that  can't  use the selection will ignore it.  As in Command Mode,
201           it is possible to specify a numeric argument.   Commands  that  can
202           take the selection as an argument will ignore the numeric argument.
203
204       Insert Mode
205           In Insert Mode the bytes you type are inserted at the current posi‐
206           tion of the cursor.  At any time, you can toggle the active  column
207           (hex  column  or  text column) by pressing the TAB key.  If the hex
208           column is active the bytes are entered as two digit hex numbers, if
209           the  text  column  is  active, the bytes are entered as ASCII text.
210           The Delete or BackSpace key deletes the previously  inserted  byte.
211           If  the  hex  column is active, the previously inserted nibble (hex
212           digit) is deleted.  It is not possible to delete  more  bytes  than
213           have  been inserted in the current insert command.  While in Insert
214           Mode, you can move the cursor using the arrow keys.  Note that mov‐
215           ing  the  cursor  discards the numeric argument given to the insert
216           command.  To leave the Insert Mode,  type  Escape.   If  a  numeric
217           argument  n was given to the insert command and is hasn't been dis‐
218           carded by a cursor movement, the typed bytes are inserted n times.
219
220       Replace Mode
221           In Replace Mode you replace the bytes under the cursor as you type.
222           Hitting  BackSpace  restores  the  original contents of the buffer.
223           The effect of a numeric argument is similar to the Insert Mode: the
224           typed  bytes  are  replaced n times.  As in Insert Mode, moving the
225           cursor using the arrow keys discards the numeric argument.
226
227       Exh Mode
228           The Exh Mode in hexer is kept similar to the ex-mode in vi.   Typi‐
229           cally, an exh command looks like:
230
231           :area command arguments
232                  Perform the command command on the area area.
233
234
235           :command arguments
236                  Perform  the command command at the current posi‐
237                  tion.
238
239           :area  Select the area area.
240
241           :position
242                  Move the cursor to position position.
243
244           An area may be defined as:
245
246           position1,position2
247                  The area starts at position1 and  ends  at  posi‐
248                  tion2 (inclusive).
249
250           position
251                  The area selects one byte at position
252
253           %      The area selects the entire buffer.
254
255           A position may be defined as:
256
257           offset A decimal, octal (prefixed with `0') or hex (pre‐
258                  fixed with `0x') number.
259
260           .      The beginning of the buffer.
261
262           $      The end of the buffer.
263
264           /regexp/
265                  A regular expression (see section REGULAR EXPRES‐
266                  SIONS).   The buffer is searched forward starting
267                  at the current position.  If a match  was  found,
268                  the  current  position  is set to the position of
269                  the match.
270
271           ?regexp?
272                  The buffer is searched reverse.
273
274           Commands may be abbreviated with a unique prefix of  the
275           command,  some commands may be abbreviated with a single
276           character, even if that character isn't a unique  prefix
277           of  the  command name.  Currently the following commands
278           are supported:
279
280           s, substitute
281                  Synopsis: area s /regexp/replace/flags
282                  Search for  the  regular  expression  regexp  and
283                  replace  it  with  replace  (see  section REGULAR
284                  EXPRESSIONS).  replace may contain `\' references
285                  to subexpressions of regexp.  flags:
286
287                  g:     global,  this  flag is ignored (it doesn't
288                         make sense in a binary editor).
289
290                  c:     confirm, ask the user to confirm each sub‐
291                         stitution.
292
293                  (Note  that  the  `/' character used as separator
294                  could be any character, it's just common practice
295                  to  use `/'.) Trailing separators may be omitted.
296                  If area is omitted, the whole buffer is searched.
297
298           w, write
299                  Synopsis: area w filename
300                  Write area to the  file  filename.   If  area  is
301                  omitted. the whole buffer is written to the file,
302                  if filename is omitted, the  filename  associated
303                  with the buffer is used.
304
305           r, read
306                  Synopsis: position r filename
307                  Insert the contents of the file filename at posi‐
308                  tion.  If position is omitted, the current  posi‐
309                  tion is used.
310
311           e, edit
312                  Synopsis: e name or: e #
313                  Change  to buffer name.  If there is no such buf‐
314                  fer, hexer tries to open a file  named  name  and
315                  load  it  into  a  new buffer.  If name is a hash
316                  sign (#), the alternate buffer is  selected.   On
317                  success  the current buffer becomes the alternate
318                  buffer.
319
320           b, buffer
321                  Synopsis: b name
322                  or: b
323                  Change to buffer name.  On  success  the  current
324                  buffer  becomes the alternate buffer.  If name is
325                  omitted, a list of all buffers is displayed.
326
327           n, next
328                  Select the next buffer in the buffer list.
329
330           N, previous
331                  Select the previous buffer in th buffer list.
332
333           S, skip
334                  Select the next unvisited buffer  in  the  buffer
335                  list.
336
337           rewind Select the first buffer in the buffer list.
338
339           wall   Write all unsaved buffers.
340
341           c, close
342                  Synopsis: c name
343                  or: c!  name
344                  or: c
345                  or: c!
346                  Close  the  buffer name.  If name is omitted, the
347                  current buffer is closed.  If the buffer has been
348                  modified, but not saved, it can't be closed using
349                  a :c-command; use :c!  to override.
350
351           h, help
352                  View an online help text.
353
354           q, quit
355                  Synopsis: q name
356                  or: q!  name
357                  or: q
358                  or: q!
359                  Close all buffers and exit  the  editor.   If  an
360                  opened  buffer  has  bee modified, but not saved,
361                  the :q-command can't be performed;  use  :q!   to
362                  override.
363
364           map
365
366           imap
367
368           vmap   Synopsis: map from to
369                  or: imap from to
370                  or: vmap from to
371                  The  key sequence from is mapped to to.  To enter
372                  special keys  (e.g.  function  keys),  mask  them
373                  using  Control-V.   :map affects the Command Mode
374                  only, :imap affects  the  Insert  Mode  only  and
375                  :vmap  affects  the  Visual Mode only.  It is not
376                  possible to re-map key sequences on  the  command
377                  line editor.
378
379           unmap
380
381           iunmap
382
383           vunmap Synopsis: unmap from
384                  or: iunmap from
385                  or: vunmap from
386                  Delete  a key mapping created with :map, :imap or
387                  :vmap.
388
389           set    Synopsis: set variable [...]
390                  or: set variable=value [...]
391                  or: set novariable [...]
392                  or: set
393                  There are not too many variables  that  could  be
394                  modified,  this might change though.  The follow‐
395                  ing variables can be used: iso  (bool):   display
396                  the whole ISO-8859/1 character set; ascii (bool):
397                  display ASCII  characters  only;  TERM  (string):
398                  the name of the terminal; maxmatch (number), spe‐
399                  cialnl (bool): see section  REGULAR  EXPRESSIONS.
400                  :set  called  without an argument lists all vari‐
401                  ables and values.
402
403           d, delete
404                  Synopsis: area d
405                  Delete all bytes in area.  The deleted bytes  are
406                  copied to the kill buffer.
407
408           y, yank
409                  Synopsis: area y
410                  Copy the bytes in area to the kill buffer.
411
412           version
413                  Display the version number of hexer.
414
415           zz     Place  the  cursor  in  the  middle  line  of the
416                  screen.  Note that the  screen  is  scrolled  (if
417                  necessary);   the   cursor   position   is   kept
418                  unchanged.
419
420           zt     Place the cursor in the top line of the screen.
421
422           zb     Place the  cursor  in  the  bottom  line  of  the
423                  screen.
424
425           wq     The same as :x.
426
427           x, exit
428                  Save all buffers and exit the editor.
429
430           If  a  command  is  called and can't use the given posi‐
431           tions, areas or  arguments,  the  additional  positions,
432           areas, arguments are ignored.
433           Conditional  commands:  It is possible to specify a list
434           of terminal names for which the given command should  be
435           executed. The syntax is:
436                  :terminals:command
437           where  terminals  is  a colon-separated list of terminal
438           names.  The command is executed if and only if the value
439           of  TERM  is in the list.  I.e. you could have a command
440           like
441                  :xterm:set iso
442           in your .hexerrc-file (use the ISO character set only if
443           working on an xterm).
444
445       Cursor Motion
446           In  Command  Mode,  Insert Mode, Replace Mode and Visual
447           Mode, you can use the following cursor motion commands:
448
449           Arrow Keys
450                  Move the cursor.
451
452           Control-F
453                  Move forward one page.
454
455           Control-B
456                  Move back one page.
457
458           Control-D
459                  Move forward half a page.
460
461           Control-U
462                  Move back half a page.
463

COMMAND LINE EDITING

465       On the command line you can use the following commands:
466
467       UpArrow DownArrow
468              Move up and down through the history of  the  current
469              context.
470
471       LeftArrow RightArrow
472              Move the cursor.
473
474       Control-A
475              Move the cursor to the beginning of the line.
476
477       Control-E
478              Move the cursor to the end of the line.
479
480       Control-K
481              Delete  all  characters from the current cursor posi‐
482              tion up to the end of the line.
483
484       Control-U
485              Delete all characters from the beginning of the  line
486              up to the current cursor position.
487
488       Delete
489
490       BackSpace
491              Delete the character left of the cursor.
492
493       Control-D
494              Delete the character under the cursor.
495
496       Enter Return
497              Accept the line.
498
499       Escape Discard the line.  Note: This is different from vi.
500
501       TAB    Try to complete currently typed word.  If the comple‐
502              tion is not unique, the word is completed as  far  as
503              unique.   If  the  TAB  key  is hit twice on the same
504              position,  a list of all possible completions is dis‐
505              played.
506

REGULAR EXPRESSIONS

508       In this section it is assumed that you are familiar with REs
509       (regular expressions).  In  most  applications  (egrep,  vi,
510       ...)   REs  work  on lines, that means it is not possible to
511       use a RE containing a line break  (newline  character).   In
512       hexer,  the buffer is not split up into distinct lines and a
513       newline character is considered to be a `normal'  character,
514       now  here's the problem: imagine searching for "a.*b" in a 5
515       MB file, this would take very long (might be up  to  several
516       minutes  on  a slow machine).  That's why there's a maxmatch
517       limit (a repeat operator matches  at  most  maxmatch  occur‐
518       rences  of  its  operand).  The default value of maxmatch is
519       1024, but it may be customized using the :set-command.   For
520       simple  expressions (expressions for which the length of the
521       match can be determined from the expression) it is  possible
522       to  override  the  maxmatch limit by doubling the `*' or `+'
523       operator, e.g. "a.**b" or "foo\(bar\)\+\+".
524       Note that the context specifiers `^'/`$' (beginning/end of a
525       line)  and `\<'/`\>' (beginning/end of a word) are available
526       and actually do what you expect.   If  you  don't  want  the
527       atoms  `.'  and  `[^...]' to match the newline character you
528       can set the specialnl option using the :set-command.
529       To enter a special character, you can  use  the  standard  C
530       `\'‐escape  sequences.  To enter a character using its octal
531       code, use a `\o'‐prefix followed by up to three  octal  dig‐
532       its.   (C-style  octal  escapes  are  not supported, because
533       `\0', ... `\9' are interpreted as back-references to  subex‐
534       pressions  of  the RE.)  To enter a character using it's hex
535       code, type a `\x'-prefix followed by up to two  hex  digits;
536       decimal codes can be entered using a `\d'‐prefix followed by
537       up to three decimal digits.  It is possible to enter strings
538       of  codes  by doubling the base specifier, e.g. "\xxfe ff 5a
539       7e" or "\oo276 277 132 176".  Note that  such  a  string  is
540       treated  as  an  atom,  i.e.  the RE "\xxff fe*" matches any
541       number (< maxmatch) of repetitions of ff fe.
542       It is possible to use all  kinds  of  character  `\'‐escapes
543       (escapes    representing    a   single   character)   within
544       `[]'‐ranges.  Within a range, the  `o'  selecting  an  octal
545       base  for  the  escape may be omitted, since back-references
546       within a range don't make sense.  When specifying a  minimum
547       and/or maximum number of repetitions using the `\{,}'‐opera‐
548       tor, the numbers may be given in decimal (no prefix),  octal
549       (`0'-prefix)  or hex (`0x'-prefix).  If no maximum number is
550       specified and the operand is not  a  simple  expression,  at
551       most maxmatch matches will be found.
552

CALCULATOR

554       Hexer  provides  a  simple  calculator  (myc) capable of all
555       operations available in C.  To  enter  a  myc  command  just
556       enter  a  %  (percent) sign and an expression in infix nota‐
557       tion.  It is possible to use parentheses.   myc  understands
558       the  following binary infix operators (from highest priority
559       to lowest): ** (power), * (multiply), /  (divide),  %  (mod‐
560       ulo),  +  (add),  -  (subtract),  << (shift left), >> (shift
561       right), < (less),  <=  (less  or  equal),  >  (greater),  >=
562       (greater  or  equal),  == (equal), != (not equal), & (arith‐
563       metical and), | (arithmetical or), ^ (arithmetical exclusive
564       or), && (logical and), || (logical or), = (assign);  and the
565       following unary prefix operators: - (negate, unary minus), !
566       (logical not), ~ (bitwise complement).  myc knows three data
567       types: boolean, integer (32 bit), float (64 bit,  equivalent
568       to  C  double).  On some esoteric platforms the precision of
569       integer and float may be different.  As in C the result of a
570       division  depends  on  the  data  types of the operands.  An
571       integer divided by an integer yields  an  integer.   If  you
572       want the result to be a float, make sure one of the operands
573       is a float, e.g. type  4/7.   instead  of  4/7  or  a/(b+0.)
574       instead  of a/b.  The power operation returns a float if the
575       result is too large to fit in an integer.  The result  of  a
576       calculation  is  stored  in  the special variables $$ and $n
577       where n is the number of the command.
578

BUGS

580       Probably.  Please report bugs to demetrio@cs.uni-sb.de.
581
583       hexer is not in the public domain, but freely distributable.
584       It  may  be  used  for any non-commercial purpose.  See file
585       COPYRIGHT for details.
586

AUTHOR

588       Sascha Demetrio
589       demetrio@cs.uni-sb.de
590
591
592
593
594Hexer 1.0.5                     August 28, 2018                       HEXER(1)
Impressum