2017 © Pedro Peláez
 

library vimrunner-php

Control Vim using PHP

image

mheap/vimrunner-php

Control Vim using PHP

  • Thursday, February 25, 2016
  • by mheap
  • Repository
  • 1 Watchers
  • 1 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

vimrunner-php

This is a hugely untested library for sending commands to a remote Vim instance. For an example of how to use it, look at example.php, (*1)

Creating a client

Make sure that your vim is compiled with +clientserver with vim --version | grep clientserver. If it starts with a + it supports it. If it starts with a - it doesn't. gvim and macvim tend to come with it enabled., (*2)

Start vim with vim --servername FOO to start it with the remote server enabled., (*3)

In your script, create a new client like so:, (*4)

$c = new Vimrunner\Client("FOO");

All of the available commands so far are in src/Vimrunner/Client.php., (*5)

Available commands

The most common command will be writeLine., (*6)

// 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 will put you in normal mode once they're done typing., (*7)

Other useful methods:, (*8)

// 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");

The Versions

25/02 2016

dev-master

9999999-dev

Control Vim using PHP

  Sources   Download

MIT

25/02 2016

0.0.1

0.0.1.0

Control Vim using PHP

  Sources   Download

MIT