Script Roundup: united-front

United Front

united-front (GitHub: ardagnir / united-front, License: AGPL v3) by James Kolb is a plugin for syncing registers between instances of Vim. First a server is run with vim --servername name, and then you can connect other clients to it.

I had a look at the source to see how it works. Whenever one of the events FocusLost, CursorHold, or VimEnter is triggered, a function called SendVimInfo is run. This function calls remote_expr which causes UnitedFront_ReadFrontFile to run on the other instances.

The UnitedFront_ReadFrontFile function reads .unitedfront for registers. That file is written by WriteFrontFile which packs the desired registers based on an array called savedRegs.

It's a simple implementation but an interesting use of remote_expr and file system functions.

blog comments powered by Disqus