# HEXEDIT - view and edit files in hexadecimal or in ASCII - man(1) - [phpMan]

> **TLDR:** File editor for hexadecimal and ASCII content.
>
- Open file:
  `hexedit {{path/to/file}}`
- Display file with sectors:
  `hexedit {{-s|--sector}} {{path/to/file}}`
- Maximize file display:
  `hexedit {{-m|--maximize}} {{path/to/file}}`
- Display help:
  `hexedit {{-h|--help}}`

*Source: tldr-pages*

---

[_HEXEDIT_(1)](https://www.chedong.com/phpMan.php/man/HEXEDIT/1/markdown)                             General Commands Manual                            [_HEXEDIT_(1)](https://www.chedong.com/phpMan.php/man/HEXEDIT/1/markdown)

## NAME
       hexedit - view and edit files in hexadecimal or in ASCII

## SYNOPSIS
       _hexedit_ [-s | --sector] [-m | --maximize] [-l<n> | --linelength <n>] [-h | --help] [filename]

## DESCRIPTION
       _hexedit_  shows  a file both in ASCII and in hexadecimal. The file can be a device as the file
       is read a piece at a time. You can modify the file and search through it.

## OPTIONS
       _-s,_ _--sector_
              Format the display to have entire sectors.

       _-m,_ _--maximize_
              Try to maximize the display.

       _--color_
              Display colors.  This feature is only available if your operating system supports it.

       _-l<n>,_ _--linelength_ _<n>_
              Explicitly set the number of bytes to display per line to <n>.

       _-h,_ _--help_
              Show the usage.

**COMMANDS (quickly)**
### Moving
       <, > :  go to start/end of the file
       Right:  next character
       Left:   previous character
       Down:   next line
       Up:     previous line
       Home:   beginning of line
       End:    end of line
       PUp:    page forward
       PDown:  page backward

### Miscellaneous
       F2:     save
       F3:     load file
       F1:     help
       Ctrl-L: redraw
       Ctrl-Z: suspend
       Ctrl-X: save and exit
       Ctrl-C: exit without saving

       Tab:    toggle hex/ascii
       Return: go to
       Backspace: undo previous character
       Ctrl-U: undo all
       Ctrl-S: search forward
       Ctrl-R: search backward

### Cut&Paste
       Ctrl-Space: set mark
       Esc-W:  copy
       Ctrl-Y: paste
       Esc-Y:  paste into a file
       Esc-I:  fill

**COMMANDS (full and detailed)**
       o _Right-Arrow_, _Left-Arrow_, _Down-Arrow_, _Up-Arrow_ - move the cursor.
       o _Ctrl+F_, _Ctrl+B_, _Ctrl+N_, _Ctrl+P_ - move the cursor.
       o _Ctrl+Right-Arrow_, _Ctrl+Left-Arrow_, _Ctrl+Down-Arrow_, _Ctrl+Up-Arrow_ - move n times  the  cur‐
       sor.
       o _Esc+Right-Arrow_, _Esc+Left-Arrow_, _Esc+Down-Arrow_, _Esc+Up-Arrow_ - move n times the cursor.
       o _Esc+F_, _Esc+B_, _Esc+N_, _Esc+P_ - move n times the cursor.
       o _Home_, _Ctrl+A_ - go the beginning of the line.
       o _End_, _Ctrl+E_ - go to the end of the line.
       o _Page_ _up_, _Esc+V_, _F5_ - go up in the file by one page.
       o _Page_ _down_, _Ctrl+V_, _F6_ - go down in the file by one page.
       o _<_, _Esc+<_, _Esc+Home_ - go to the beginning of the file.
       o _>_, _Esc+>_, _Esc+End_ - go to the end of the file (for regular files that have a size).
       o _Ctrl+Z_ - suspend hexedit.
       o _Ctrl+U_, _Ctrl+__, _Ctrl+/_ - undo all (forget the modifications).
       o  _Ctrl+Q_  -  read  next  input character and insert it (this is useful for inserting control
       characters and bound keys).
       o _Tab_, _Ctrl+T_ - toggle between ASCII and hexadecimal.
       o _/_, _Ctrl+S_ - search forward (in ASCII or in hexadecimal, use _TAB_ to change).
       o _Ctrl+R_ - search backward.
       o _Ctrl+G_, _F4_ - go to a position in the file.
       o _Return_ - go to a sector in the file if _--sector_ is used, otherwise go to a position in  the
       file.
       o _Esc+L_ - display the page starting at the current cursor position.
       o _F2_, _Ctrl+W_ - save the modifications.
       o _F1_, _Esc+H_ - help (show the man page).
       o _Ctrl+O_, _F3_ - open another file
       o _Ctrl+L_ - redisplay (refresh) the display (useful when your terminal screws up).
       o _Backspace_, _Ctrl+H_ - undo the modifications made on the previous byte.
       o _Esc+Ctrl+H_ - undo the modifications made on the previous bytes.
       o _Ctrl+Space_, _F9_ - set mark where cursor is.
       o _Esc+W_, _Delete_, _F7_ - copy selected region.
       o _Ctrl+Y_, _Insert_, _F8_ - paste (yank) previously copied region.
       o _Esc+Y_, _F11_ - save previously copied region to a file.
       o _Esc+I_, _F12_ - fill the selection with a string
       o _Esc+T_ - truncate the file at the current location
       o _Ctrl+C_ - unconditional quit (without saving).
       o _F10_, _Ctrl+X_ - quit.

       For  the _Esc_ commands, it sometimes works to use _Alt_ instead of _Esc_. Funny things here (espe‐
       cially for froggies :) egrave = Alt+H , ccedilla = Alt+G, Alt+Y = ugrave.

### Modeline
       At the bottom of the display you have the modeline (copied from emacs). As in emacs, you have
       the indications --, ** and %% meaning unmodified, modified and read-only. Then you  have  the
       name  of  the file you're currently editing. Next to it is the current position of the cursor
       in the file followed by the total file size. The total file size isn't quite correct for  de‐
       vices.
       While in --sector mode, it shows the sector the cursor is in.

### Editing
       You  can  edit  in ASCII or in hexadecimal. You can switch between the two with _Tab_. When the
       file is read-only, you can't edit it. When trying to edit a read-only file, a  message  "File
       is read-only" tells you it is non-writable.
       The modifications are shown in bold until they are saved.  The modeline indicates whether you
       have modified the file or not.
       When  editing  in hexadecimal, only _0_,_1_,...,_9_, _a_,_b_,...,_f_, _A_,_B_,..._F_ are legal.  Other keys are
       unbound. The first time you hit an unbound key, the help pops up.  It won't pop again  unless
       you call the help directly (with _F1_).
       When  editing  in ascii, you can find it difficult to enter characters like _/_ which are bound
       to a function. The solution is to use the quoted insert function _Ctrl+Q_, the  key  after  the
       quoted  insert function is not processed by _hexedit_ (like emacs' quoted-insert, or like the \
       character in C).

### Searching
       You can search for a string in ASCII or in hexadecimal. You can switch between the  two  with
       _Tab_.  If  the string is found, the cursor is moved to the beginning of the matching location.
       If the search failed, a message "not found" tells you so. You can cancel the search by press‐
       ing a key.
       The search in hexadecimal is a bit confusing. You must give a hexadecimal string with an even
       number of characters. The search can then be done byte by byte. If you want to search a  long
       number  (eg: a 32 bit number), you must know the internal representation of that number (lit‐
       tle/big endian problem) and give it the way it is in memory. For example, on an Intel proces‐
       sor (little endian), you must swap every bytes: 0x12345678 is written  0x78563412  in  memory
       and that's the string you must give to the search engine.
       Before searching you are asked if you want to save the changes, if the file is edited.

       For   more   sophisticated   search,   see   Volker  Schatz's  patch  at  <<http://www.volker>‐
       schatz.com/unix/homebrew.html#hexedit>.

### Selecting, copying, pasting, filling
       First, select the part of the buffer you want to copy: start setting the mark where you want.
       Then go to the end of the area you want to copy (you can use  the  go  to  function  and  the
       search functions). Then copy it. You can then paste the copied area in the current file or in
       another file.

       You  can  also  fill the selected area with a string or a character: start choosing the block
       you want to fill in (set mark then move to the end of the block), and call the fill  function
       (_F12_). _hexedit_ ask you the string you want to fill the block with.
       The code is not tuned for huge filling as it keeps the modifications in memory until you save
       them. That's why _hexedit_ will warn you if you try to fill in a big block.

       When the mark is set, the selection is shown in reverse mode.
       Be aware that the copied area contains the modifications done at the time of the copy. But if
       you undo the modifications, it does not change the content of the copy buffer. It seems obvi‐
       ous but it's worth saying.

### Scrolling
       The  scrolling  is  different  whether  you  are in _--sector_ mode or not. In normal mode, the
       scrolling is line by line. In sector mode, the scrolling is sector by sector. In both  modes,
       you can force the display to start at a given position using _Esc+L_.

## SEE ALSO
       [od(1)](https://www.chedong.com/phpMan.php/man/od/1/markdown), [hdump(1)](https://www.chedong.com/phpMan.php/man/hdump/1/markdown), [hexdump(1)](https://www.chedong.com/phpMan.php/man/hexdump/1/markdown), [bpe(1)](https://www.chedong.com/phpMan.php/man/bpe/1/markdown), [hexed(1)](https://www.chedong.com/phpMan.php/man/hexed/1/markdown), [beav(1)](https://www.chedong.com/phpMan.php/man/beav/1/markdown).

## AUTHOR
       Pixel (Pascal Rigaux) <<pixel@rigaux.org>>,
       Home page is <<http://rigaux.org/>>.

## UNRESTRICTIONS
       _hexedit_  is  Open Source; anyone may redistribute copies of _hexedit_ to anyone under the terms
       stated in the GNU General Public License.

       You can find _hexedit_ at
       <<https://github.com/pixel/hexedit/archive/1.6.tar.gz>>

## TODO
       Anything you think could be nice...

## LIMITATIONS
       There are problems with the curses library given with Redhat 5.0 that make _hexedit_ think  the
       terminal is huge. The result is that hexedit is not usable.

       The  shortcuts  work on some machines, and not on others. That's why there are many shortcuts
       for each function. The Ctrl+Arrows and the Alt+. do not work work as they should most of  the
       time.  On  SUNs, you must do Ctrl+V-Ctrl+V instead of Ctrl+V (!); and the Alt key is the dia‐
       mond one.

       While searching, it could be interesting to know which position the search has reached.  It's
       always nice to see something moving to help waiting.

       The hexadecimal search could be able to search modulo 4 bits instead of 8 bits.  Another fea‐
       ture could be to complete padd odd length hexadecimal searches with zeros.

## BUGS
       I have an example where the display is completely screwed up. It seems to be a bug in ncurses
       (or  maybe  in xterm and rxvt)?? Don't know if it's me using ncurses badly or not... It seems
       to happen when _hexedit_ leaves only one space at the end of the lines... If anyone has  a  (or
       the) solution, please tell me!

       If  you  have any problem with the program (even a small one), please do report it to me. Re‐
       marks of any kind are also welcome.

                                            12 July 1998                                  [_HEXEDIT_(1)](https://www.chedong.com/phpMan.php/man/HEXEDIT/1/markdown)
