Skip to content

Instantly share code, notes, and snippets.

@hyuki0000
Last active July 7, 2016 00:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hyuki0000/db4572c5ece783755ff0875e05a10bcd to your computer and use it in GitHub Desktop.
Save hyuki0000/db4572c5ece783755ff0875e05a10bcd to your computer and use it in GitHub Desktop.
一行目に書いた文字列を利用して、指定した範囲の先頭にそれを書き込むVim のformatprg
set formatexpr=""
set formatprg=/YOUR/BIN/DIR/formatprg.rb
#! /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
@hyuki0000
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment