Skip to content

ryanjosephking/reval.vim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

reval.vim - Quick edit/filter/see loop, especially for regex testing.

= Intro =

The idea comes from (sites like) http://rubular.com/ where you can input a
regex, then see it filter the results. Though a really cool use of AJAX, who
would rather be in a web form than in their very own text editor?

Hence reval.vim. All it does is use your top buffer as the argument to a
command, such as "perl -0400 -pe", then uses the left buffer as that command's
stdin, with the right buffer capturing stdout. This means that, though it is
geared for regex testing by default, you could do anything with the loop that
you want.

= Install =

 * make install - Will put the `reval.vim` into ~/.vim/plugin/, and check to see
     if you have a ~/bin/ -- if you do, it will put the `reval` script there.
 * make ruby - Switch your ~/.reval.vimrc to use Ruby by default.
 * make uninstall - To make rking sad. =(

= Options =

You can set these options:
 * In your ~/.reval.vimrc with let g:revallang = 'ruby'
 * Within vim with :let g:revallang = 'ruby'
 * From the command-line with vim +'let g:revallang = ruby'
 * In your vim rc files with let g:revallang = 'ruby'

g:revallang - Switches the file, cmd, and "body"-regexp to match your language
  choice. Currently available: perl and ruby. Default is:
    let g:revallang = 'perl'

g:revalrunner - The command and arguments to use for the filter. (Note: You
    can temporarily set this to 'perl -p -mre=debug' for one run by hitting \d
    instead of F5)
  Default when 'perl' == g:revallang is:
    let g:revalrunner = 'perl -p'

g:revalfile - The filename of the loop body itself. The extension will hint
  vim on how to syntax highlight. Example when 'perl' == g:revallang is:
    let g:revalfile = '/tmp/GARBLE/0-reval.pm'

g:revalbody - The starting contents of your buffer. 
  Default when 'perl' == g:revallang is:
    let g:revalbody = 's//…/g'

g:revalinput - The file to use for input. Default is:
  let g:revalinput = '/tmp/revalinput'

g:revallinewise - Defaults to off ("0"), which will treat the input file as a
  whole string.  This is a farily aggressive default, but I believe it is more
  the way you expect it to work, so that \A means the beginning of the file,
  not each line, for example.  If you are doing much customization of the
  above variables, you'll probably want to 'let g:revallinewise = 1' so that
  it prevents the addition of the '-0400' argument to your g:evalrunner.

g:revalcmd - Pieces together the previous bits to make the actual command. If
  you want to get really fancy, this is the way to control it. After
  executing, reval.vim will use this command's stdout for the output buffer.
  Default is:
    let g:revalcmd = g:revalrunner.' '.g:revalfile.' 2>&1 < '.g:revalinput

= For More =

An amazing, interactive regex lesson is here:
  * Get on Freenode IRC - http://freenode.net/using_the_network.shtml
  * /join #regex  (So the bot will talk to you -- but it's a good
      channel, anyway)
  * /msg pork !register yournick apassword
  * /msg pork !regexquiz
  * ...then have fun!

Some regex resources are:
  * Perl's Documentation - http://perldoc.perl.org/perlre.html
  * The table of implementation comparisons (search for "Backslash"...)
        - http://www.regular-expressions.info/refflavors.html
  * The web versions of this script (often better in several ways):
      * http://rubular.com/ - Ruby
      * http://regextester.com/ - JavaScript, Perl, and PHP REs
  * The Komodo IDE's Rx Toolkit - http://www.activestate.com/komodo-ide
  * pcretest from the PCRE lib - http://www.pcre.org/
      * In my opinion, the -b option to print its internal format is not as
        nice as `perl -mre=debug` (which is invoked if you hit \d from reval)
  * ...

About

An edit/filter/view loop in the spirit of http://rubular.com

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published