6xc9jw
Last Updated: September 15, 2018
·
101
· ryrych

Using Vim buffer as a standard input and output for shell commands

vim

Vim buffer can be used both as an input and output for other shell commands.

Output example

:!ls

Input example

Suppose that you liked the Today I learned idea and after some time you would like to get some statistics about your writing using lingua module.

#!/usr/bin/env ruby

require 'lingua'
input = ARGF.read

report = Lingua::EN::Readability.new(input)
puts report.report

By the way the file content above has been inserted with :read ~/lingua.rb. Now getting statistics is as easy as this:

:write ! ruby ~/linuga.rb

Number of paragraphs           259 
Number of sentences            136 
Number of words                1400 
Number of characters           9885 

Average words per sentence     10.29 
Average syllables per word     1.48 

Flesch score                   70.94 
Flesh-Kincaid grade level      5.92 
Fog Index                      7.75 

Please note that the whole buffer content has been redirected to standard input that lingua.rb accepts.

1 Response
Add your response

30694

Your post is very good and meaningful. How long will it take you to write and post? thank you for sharing
http://slitherio-o.com

about 1 month ago ·