I'm trying to create a macro for an action that I very frequently use in Python: printing a variable in a bright color so it can easily be found in the traces while debugging.
So lets say there's something like...
I want the macro to add
print("\u001b[35m", myvariable, "\u001b[0m")
on the line below it. (assuming the cursor was anywhere in the word "myvariable")
I tried writing the macro by hand, but I quickly had to realize that I'm still too noobish for that. Instead I recorded the macro, and tried to save that by using the CTRL-R CTRL-R method.
However, it appears for some reason the macro isn't properly "pasted" to my vimrc from the register. The
o-register in code down below is directly recorded to the register. The
p-register is the one that it got from the vimrc (after pasting from register).
c "o yawA^Mprintf(<80>kb<80>kb("\u001b[35m", ^[<80><fd>apA, "\u001b[0m")^[<80><fd>a c "p yawA^Mprintf(<80>kb<80>kb("\u001b[35m", ^[<80>ýapA, "\u001b[0m")^[<80>ýa
As you can see, it is slightly different.
<fd> has changed into
ý for some reason. Anyone who can explain my why this is and how I can fix it?
(Ps. I know some of you will be tempted to just give me a working macro instead. Those answers are also welcome, but keep in mind that I did not use
O on purpose, but instead used
A[ENTER] so that the Python-indentation is retained. )
EDIT: I just noticed something else that's odd! In the macro snippets above it says printf, while if I use the macro it uses a regular print! This is so odd?
EDIT2: I didn't make it very clear, but the macro in register
p does not work. This is what I get when using it: