Use VIM with Xxd to view and edit binary files under Linux

Source: Internet
Author: User
Tags ultraedit

Generally speaking, the file is divided into two major categories of text and binary files, text file editing is easy, Windows Notepad, UltraEdit are very useful, binary file editing under Windows also has a lot of tools, UltraEdit is good, but Linux? Today finally found a good way, but the final source can not find.

First create a binary file:

[Email protected] tmp]$ echo-n "abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz" > Test.bin

[email protected] tmp]$ cat Test.bin

ABCDEFGHIJKLMNOPQRSTUVWXYZ Abcdefghijklmnopqrstuvwxyz[[email protected] tmp]$

Note that echo must keep up with the-n option, otherwise it will be automatically added with a newline line and then opened with Vim Test.bin

[Email protected] tmp]$ Vim-b Test.bin

Vim's-B option is to tell vim to open a binary file, which, if not specified, is appended with 0x0a, a newline character.

In command mode, type:

:%!xxd

If Vim is not followed by the-B option, The Hateful 0x0a will appear:


This is not the case if the-B option is available:

Then go to edit mode change, I will change a, b corresponding 41, 42 to 61, 62, A, b corresponding 61, 62 to 41, 42.

Back to command mode input:

:%!xxd-r

At this point we can find the position of AB and AB are interchangeable.

Finally, enter in command mode: Wq save to exit.


Use VIM with Xxd to view and edit binary files under Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.