Last active
July 7, 2016 00:49
-
-
Save hyuki0000/db4572c5ece783755ff0875e05a10bcd to your computer and use it in GitHub Desktop.
一行目に書いた文字列を利用して、指定した範囲の先頭にそれを書き込むVim のformatprg
This file contains 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
set formatexpr="" | |
set formatprg=/YOUR/BIN/DIR/formatprg.rb |
This file contains 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/ruby | |
# これはVimの中から gq{motion}で実行されるフィルタ | |
lines = [] | |
STDIN.readlines.each do |line| | |
lines << line.chomp | |
end | |
command = lines.shift | |
case command | |
when 'item' | |
lines.each do |line| | |
puts "\\item #{line}" | |
end | |
when '%', '#', '//', '・', '"' | |
lines.each do |line| | |
puts "#{command} #{line}" | |
end | |
else | |
puts command | |
puts lines | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
使い方など
https://twitter.com/hyuki/status/750547732507553792