How to make a valid input for “xxd -r” in vim when removing a byte?

前端 未结 1 1331
梦如初夏
梦如初夏 2021-01-18 22:14

Create a file named as test containing the following content:

0123456789abcdef0123456789abcdef

I want to remove the first

相关标签:
1条回答
  • 2021-01-18 22:20

    You've discovered on your own that removing the byte offset column and text column allows you to use :%!xxd -r -p to get what you want. So how about creating a custom command to remove those columns and then do the conversion? :%!xxd -r -p is too much to type, anyway.

    Something like:

    :command MyXXDR %s#^[^:]*: \(\%(\x\+ \)\+\) .*#\1# | %!xxd -r -p
    

    This exact command may cause problems if you have messed up the format of the file too much with your edits (i.e. if the substitute command doesn't match to remove the necessary text), but you get the idea.

    0 讨论(0)
提交回复
热议问题