From: Ned Konz Date: 2002-07-06T08:48:49+09:00 Subject: Ruby extensions for VIM OK, here's a file that you can put in your ~/.vim/plugin directory that will extend Vim's Ruby model to allow sort, each, etc. as well as whole buffer replacements like: ruby $curbuf.set_to( $curbuf.sort ) ruby $curbuf.set_to( $curbuf.grep(/abc/)) " Extension to built-in Ruby support to add enumerable (each, sort, etc.) to " both VIM::Buffer (class & instance) and VIM::Window (class) if has("ruby") ruby < arr.size self.delete(count) end else arr.each_with_index do |s,i| if i+1 <= count self[i+1] = s else append(i, s) end end end end # each buffer... def self.each(&block) (0..count-1).each { |n| block.call(self[n]) } end end class Window include Enumerable # each window... def self.each(&block) (0..count-1).each { |n| block.call(self[n]) } end end end EOF endif