vim macro across screen windows

57 Views Asked by At

I have recorded a vim macro in one screen window. In same screen session, I have multiple windows.

How to make macro I recorded in 1st screen window across other screen windows / across screen sessions ?

Do we have to do something with vim registers for this ?

1

There are 1 best solutions below

0
romainl On
  • If the two screen windows show two separate Vim instances on the same machine

    • If Vim is built with clipboard support

      1. In the Vim instance where you recorded that macro, put the content of the macro's register into the clipboard register:

        " assuming you recorded your macro in register `a`
        :let @+ = @a
        
      2. In the other Vim instance, put the content of the clipboard register into a named named register:

        :let @a = @+
        
    • If Vim is not built with clipboard support

      Vim stores registers in a .viminfo file. You are theoretically allowed to write to and read from arbitrary .viminfo files but it can lead to unwanted loss of state in Vim. Read :help viminfo-read-write very carefully and proceed with caution.