Created
January 22, 2015 15:39
-
-
Save nocd5/a0931bde6e5901855028 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # command! -nargs=* -range AlignEqual <line1>,<line2>!ruby C:\Tools\bin\runtime\AlignEqual.rb <args> | |
| Pattern = "(.*?)(#{ARGV.size.zero? ? "=" : ARGV[0]})(.*\n)" | |
| @Lines = STDIN.read | |
| # get max length | |
| $MaxLen = 0 | |
| @Lines.each_line{ |line| | |
| $MaxLen = [$1.length, $MaxLen].max if (line =~ /#{Pattern}/) | |
| } | |
| # put lines | |
| @Lines.each_line{ |line| | |
| if (line =~ /#{Pattern}/) | |
| puts $1 + " "*($MaxLen - $1.length) + $2 + $3 | |
| else | |
| puts line | |
| end | |
| } | |
| # vim: et ts=2 sw=2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment