Is it possible to do inbuffer calculation in emacs.
For example, if my file has the following numbers
10
11
12
(A) I would like to convert these numbers to hex (either in place or paste it next to that),
10 A
11 B
12 C
(B) I would like to sum those numbers.
10
11
12
33
(C) I would like to increment the count (sth like an index)
10
11
12
13
14
You can use the inbuilt calculator and/or the fact that \,
in the replacement string for commands like replace-regexp
will evaluate an arbitrary elisp expression.
More-or-less of the top of my head you can do:
A.
\([[:digit:]]+\)
.\,(format "%X" (string-to-number \1))
.B.
C.
Same as for A, but mark just the last number, and use a replacement function of \,(format "%s\n%d" \1 (1+ (string-to-number \1)))
.
You can put these in macros or functions which take care of moving point around to the right place.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With