Skip to main content
10 of 10
added 2 characters in body; edited title
Vivian De Smedt
  • 21.1k
  • 5
  • 22
  • 40

Individual macros function but combined macros do not

I am trying to brute-force the Caesar shift cipher in vim. I have recorded three macros f, a, and d where f copies the line and a applies a Caesar shift to all elements on the line by calling macro d which Caesar shifts a char. Both macros work fine individually, and when I spam @f@a on my keyboard, but when I create a new macro @f@a using any other register, the macro doesn't function properly, it doesn't create a new line and appears to only Caesar shift the current line.

This is my text file w/ macros#

# abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
# bcdefghijklmnopqrstuvwxyzaBCDEFGHIJKLMNOPQRSTUVWXYZA

"brute-forcing Caesar shift cipher w/ vim macros

"input is given at bottom of file

"subroutines
""duplicate bottom line
call:f
yyp

""Caesar shift line
call:a
!!wc -c^M0Yuo^[<80>ýapa@d^[<80>ýa0"rDk@r

""Caesar shift character
call:d
mfyl3Gpif^[<80><fd>alajyl^[<80><fd>a0"sD1G@s`fvpl


hello world

Edit: the new macro I was referring to was @f@a. The key sequence @f@a works fine but @x where @x=@f@a where x is any register does not behave the same. Can anyone reproduce this behavior?

Edit: I have included macro d. Note: macro r is recorded in macro a. I understand the vim macros are incomprehensible but how could, even ignoring the macros, a key-sequence like @f@a be different than @x which has @f@a stored inside register x?