Skip to content

Instantly share code, notes, and snippets.

View kyletolle's full-sized avatar

Kyle Tolle kyletolle

View GitHub Profile
@kyletolle
kyletolle / gist:6097061
Created July 28, 2013 02:10
Automatically strip trailing whitespace from files within files in VIM.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Automatically strip trailing whitespace from lines within files
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
autocmd BufWinEnter,BufRead,InsertLeave,BufEnter * call RemoveTrailingWhitespace()
function! RemoveTrailingWhitespace()
silent! execute '%s/\s\+$//g'
endfunction
@kyletolle
kyletolle / gist:6097047
Created July 28, 2013 02:05
Highlight whitespace at the end of lines while using VIM.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Highlight whitespace at the end of lines
" From: http://vim.wikia.com/wiki/Highlight_unwanted_spaces
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
@kyletolle
kyletolle / fizzbuzz.rb
Created November 20, 2012 16:16
My FizzBuzz implementation
(1..100).each do |n|
o = ""
o << "Fizz" if (n % 3) == 0
o << "Buzz" if (n % 5) == 0
puts "#{o.empty? ? n : o}"
end