mheap/vimrunner-php
此软件包已被废弃,不再维护。未建议替代软件包。
使用PHP控制Vim
0.0.1
2016-02-25 13:23 UTC
This package is auto-updated.
Last update: 2020-11-26 18:26:58 UTC
README
这是一个未经过充分测试的库,用于向远程Vim实例发送命令。有关如何使用它的示例,请参阅example.php
创建客户端
请确保您的vim
已编译带有+clientserver
,可以使用vim --version | grep clientserver
来检查。如果它以加号开头,则表示支持。如果以减号开头,则表示不支持。gvim
和macvim
通常已启用。
使用vim --servername FOO
启动vim,以启用远程服务器。
在您的脚本中创建一个新客户端,如下所示
$c = new Vimrunner\Client("FOO");
目前所有可用的命令都在src/Vimrunner/Client.php
中。
可用的命令
最常见的命令将是writeLine
。
// Will type "Hello World", with 0.1 seconds between each key press
// and add a new line "\n" at the end
$c->writeLine("Hello World", 1);
// You can also decide how you enter insert mode
// e.g. enter in append mode
$c->writeLine("Hello World", 1, "a");
writeLine
将使您在输入完成后进入正常模式。
其他有用的方法
// Make sure we're in normal mode
$c->ensureInNormalMode();
// Send a string of key presses in normal mode
// e.g. Reformat the entire file
$c->normal("gg=G");
// Send a command
// e.g. :w
$c->command("w");
// Open a file for editing
$c->editFile("/tmp/example");