Skip to content

Instantly share code, notes, and snippets.

@spllr
Created December 29, 2010 11:18
Show Gist options
  • Save spllr/758432 to your computer and use it in GitHub Desktop.
Save spllr/758432 to your computer and use it in GitHub Desktop.
Removes all duplicate snippets in .vim/snippets which are already defined in .vim/bundle/snipmate.vim/snippets/*.snippets
puts "Remove duplicate snippets from vim conf"
Dir.chdir(File.expand_path("~/.vim/bundle/snipmate.vim"))
puts "Moved to #{Dir.pwd}"
Dir["**/*.snippets"].each do |snippet|
snippet_lang = File.basename(snippet, '.snippets')
File.open snippet, "r" do |snippet_file|
snippet_file.read.scan(/^snippet (.+)/) do |snippet_key|
target_file = File.expand_path(snippet_lang + "/" + snippet_key.join + ".snippet", File.expand_path(".vim/snippets", "~"))
if File.exists?(target_file)
puts "Found duplicate snippet: #{target_file}"
File.delete(target_file)
puts "Remove duplicate"
end
end
end
end
puts "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment