-
Notifications
You must be signed in to change notification settings - Fork 4
/
hed.1
243 lines (226 loc) · 5.8 KB
/
hed.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
.Dd July 7, 2018
.Dt HED 1 1
.Os Linux
.Sh NAME
.Nm hed
.Nd vim like hex editor
.Sh SYNOPSIS
.Nm hed
.Op Fl v
.Op Fl h
.Op FILE
.Sh DESCRIPTION
.Nm
uses vim-inspired key bindings to navigate and edit a file in hex format
The options included with the program are as follows:
.Bl -tag -width Ds
.It Fl h
displays help and exits.
.It Fl v
displays version info and exits.
.El
.Sh FILES
~/.hedrc Your personal
.Nm
initialization configuration.
.Pp
See section
.Em OPTIONS
.Sh KEY BINDINGS
All commands can be prefixed with a number 'n' to repeat it 'n' times.
.Pp
To navigate in the editor (modes: NORMAL, VISUAL):
.Pp
.Bl -item -compact -offset 2n
.It
h / left : Move cursor one byte left in the buffer.
.It
l / right : Move cursor one byte right in the buffer.
.It
j / down : Move cursor one position up.
.It
k / up : Move cursor one position down.
.It
w : Move cursor one group of bytes right.
.It
b : Move cursor one group of bytes left.
.It
gg : Go to the beginning of the file.
.It
G : Go to the end of the file. If 'n' number is typed before,
go to offset 'n' instead.
.It
0 : Go to the beginning of the line.
.It
$ : Go to the end of the line.
.It
TAB : Switch cursor position between ascii and hex.
.El
.Pp
To search for bytes in the buffer (modes: NORMAL):
.Pp
.Bl -item -compact -offset 2n
/ : Start search input forward. Can be used to search for
byte value "\\deedbeef" or strings "\\ELF" depending on
the cursor side.
.It
? : Same as before but searches backwards.
.It
n : Search for next occurrence (forward).
.It
N : Search for previous occurrence (backward).
.El
.Pp
To add, remove or insert bytes in the buffer:
.Pp
.Bl -item -compact -offset 2n
i : Enable
.Em INSERT
mode.
.It
r : Enable
.Em REPLACE
mode.
.It
v : Enable
.Em VISUAL
mode.
.It
a : Enable
.Em APPEND
mode. If 'A' is used instead, moves to the end
of the line first.
.It
] : Increment the byte at the cursor position. If 'n' is given,
increments 'n' times. (modes: NORMAL)
.It
[ : Decrement the byte at the cursor position. If 'n' is given,
decrements 'n' times. (modes: NORMAL)
.It
x / DEL : Delete byte at current cursor position. If 'n' is given,
delete 'n' bytes. (modes: NORMAL, VISUAL)
.It
dot (.) : Repeats the last write. (modes: NORMAL)
.Pp
.El
Extra key-bindings:
.Bl -item -compact -offset 2n
.Pp
: : Enable
.Em COMMAND
mode.
.It
ESC : Enable
.Em NORMAL
mode.
.It
u : Undo the last action. If 'n' is given, undoes 'n' times.
.It
CTRL R : Redo the last action. If 'n' is given, redoes 'n' times.
.El
.Sh MODES
.Nm
knows of six several modes which can be used.
.Ss NORMAL
Normal-mode is the mode where regular keys can be used to switch modes,
navigate through the buffer, etc. Hit ESC at any time to trigger
normal-mode.
.Ss REPLACE
In replace-mode, the editor replaces the current byte at the current
offset with a byte of choice. Use 'r' when in normal-mode to switch to
replace-mode.
.Ss INSERT
In insert-mode, the editor inserts a byte value at the current offset.
Use 'i' when in normal-mode to switch to insert-mode.
.Ss APPEND
In append-mode, the editor appends a byte value one position after the
current selected offset. To go into append mode, type 'a' when in
normal-mode.
.Ss VISUAL
In visual-mode, the editor shows a selection of bytes that can be either
replaced or removed with 'r' or 'x' respective. The remove and replace
is respectively all over the selection.
.Ss COMMAND
In command-mode, manual commands can be entered. This can be triggered
by typing the colon (
.Sy :
) character. Current implemented commands are:
.Pp
.Bl -item -compact -offset 2n
.It
NUM Go to offset in base 10.
.It
o[ffset] NUM Same as before.
.Pp
.It
0xHEXVALUE Go to offset in base 16.
.It
o[ffset] 0xHEX Same as before.
.Pp
.It
set [OPTION]=val See section
.Em OPTIONS
.It
.Pp
w[rite] [file] Write current buffer to disk. If file is given, write
the buffer in the new file name.
.It
e[dit] [file] Open a new file to edit, will remind to save previous
if its edited.
.It
q quit (add ! to force quit)
.El
.Sh EXAMPLES
.Pp
.Bl -item -compact -offset 2n
3j Move 3 lines down
.It
3w Move 3 bytes group to the right
.It
10x Remove the following 10 bytes
.It
10r90 Replace 10 bytes with value 0x90
.It
<TAB>10r9 Replace 10 bytes with '9' (ascii)
.It
10i90 Inserts 10 bytes with value 0x90
.It
4i9<ESC> Inserts 4 values 0x9, (0x99 0x99)
.It
0V$ Select the entire line (moving to the beginning first)
.It
0V$r0<ESC> Select the entire line and replace it with 0's
.It
ggVG Select the entire file
.It
:w out.bin Writes the current buffer to file 'out.bin'
.It
:q! Quits without saving
.It
:set bytes=4 Sets the number of bytes per group
.El
.Sh OPTIONS
All options should be prefixed with the keyword 'set'.
.Pp
.Bl -item -compact -offset 2n
bytes Number of bytes per group (default: 2)
.It
groups Number of groups per line (default: 8)
.It
insert Nibble to write first on insert mode (default: 0)
.It
replace Nibble to replace first on replace mode (default: 1)
.El
.Sh BUGS
Probably. Please send any comments or bug reports to
https://github.com/fr0zn/hed
.Pp
.Nm
uses ANSI escape sequences to render the terminal screen. Therefore
compatibility and portability may be an issue. It should work on most
modern terminal emulators.
.Sh AUTHORS
Implemented by Ferran Celades <[email protected]>, with indirect help
of Kevin Pors <https://github.com/krpors/hx>
.Sh SEE ALSO
.Xr xxd 1