If you are writing some sort of toplevel command program, you can send commands to Vim using the "netbeans" interface. From :help netbeans-intro:
> The NetBeans interface was initially developed to integrate Vim into the
> NetBeans Java IDE, using the external editor plugin. This NetBeans plugin no
> longer exists for recent versions of NetBeans but the protocol was developed
> in such a way that any IDE can use it to integrate Vim.
> The NetBeans protocol of Vim is a text based communication protocol, over a
> classical TCP socket. There is no dependency on Java or NetBeans. Any language
> or environment providing a socket interface can control Vim using this
> protocol. There are existing implementations in C, C++, Python and Java. The
> name NetBeans is kept today for historical reasons.