Created
December 29, 2010 11:18
-
-
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
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
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