GithubHelp home page GithubHelp logo

robot-vim's Introduction

RobotVim - Easy Vim Automation

RobotVim is a Ruby gem that allows you to invoke Vim from inside of Ruby programs. It was designed to allow Vim developers to TDD/BDD their Vim plugins and scripts.

Installation

To install RobotVim run

gem install robot-vim

or clone this reposity and run rake install

Dependencies

RobotVim is developed with Vim 7.3, Ruby 1.9.2, and bundler.

Example Usage

Initialization

Create an instance that will use your user's default Vim and vimrc

robot = RobotVim::Runner.new()

Create an instance with a specific Vim

robot = RobotVim::Runner.new(:vim => "/bin/vim")

Create an instance with a specific vimrc

robot = RobotVim::Runner.new(:vimrc => "something/vimrc")

Running commands

Commands are passed in as a string with one command per line.

The input file can be specified as a path to an existing input file, or as a string which RobotVim will turn into an short lived file backed buffer.

commands = <<-COMMANDS
  :s/old/new
  :normal! gg
  :call setline('.', "RobotVim")
  :call MyAwesomePluginFunction
COMMANDS


vim_response = robot.run(:input_file => "some/file.txt", :commands => commands)


input = <<-CONTENT
  This text will be used
  as the contents of my input file
CONTENT

vim_response = robot.run(:input_file => input, :commands => commands)
buffer_text = vim_response.body

VimResponse

The return value of RobotVim::Runner#run is a RobotVim::VimResponse instance with the following fields

  • body: The contents of the last buffer that was active when your commands completed
  • line_number: The line number the cursor was on when your commands completed
  • column_number: The column number the cursor was on when your commands completed

Please submit pull requests or issues if there are additional values that you want to be able to assert against

Making Assertions

Use your preferred Ruby testing library to make assertions about the VimResponse returned by RobotVim::Runner#run

Take a look at spec/integration_spec.rb for examples of asserting with Rspec

Author

RobotVim is developed by Matt Margolis | @mrmargolis | [email protected]

robot-vim's People

Contributors

killphi avatar mrmargolis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.