To set to logical line, Alt+x
set-variable, then give line-move-visual, with value nil. (t for true; nil for false).
When you play back macro, be sure the line-move-visual is the same as when you recorded it.
One thing you can do is to set
line-move-visual at the beginning of your keyboard macro, and set it back at the end.
Here's a command to toggle it.
(defun toggle-line-move-visual () "Toggle behavior of up/down arrow key, by visual line vs logical line." (interactive) (if line-move-visual (setq line-move-visual nil) (setq line-move-visual t)))
If you have a question, put $5 at patreon and message me.