Once I run vi a.out, I can type :%!xxd, but I'm unable to automate the process like

  • start vi automatically in hex mode
  • create a key mapping from F1 to :%!xxd

1 Answer 1


To start vim automatically in hex mode when editing a.out, put an autocommand like this one in your ~/.vimrc:

au BufReadPost a.out silent %!xxd

A more complete explanation with examples can be found at:

:help using-xxd

To use key mapping instead, mapping , for example, use this:

map <F3> :%!xxd<CR>
  • The last "map" suggestion is ineffective. I put that line into my .vimrc file. When I launch vi on a.out, the other configurations in .vimrc are working, but when I hit F3, i hear a beep and the cursor moves down a line. No xxd happening Nov 29, 2017 at 15:16
  • My guess is that your Vim does not know the escape sequence for <F3>. Try this: run Vim and start insert mode, e.g. by typing a. Then type Ctrl-K, not those letters but hold the Ctrl key and type the letter k. Then hit your F3 key. You should see the four characters <F3>. You will probably see something else. If so, the reason could be that your $TERM variable does not match the terminal you are actually using, or the code for your F3 key is missing from your terminal's terminfo database entry. One solution would be to create another mapping to define <F3>, e.g.,
    – garyjohn
    Nov 29, 2017 at 16:07
  • map <Esc>[13~ <F3>.
    – garyjohn
    Nov 29, 2017 at 16:07
  • Something else you can do to see what terminal keys Vim knows about, usually from the termcap/terminfo database, is to execute :set termcap.
    – garyjohn
    Nov 29, 2017 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.