function! DeleteAnsiColorCodes()
  set modifiable
  set noconfirm
  " Clean ascii/ansi code  (starts with ^[)
  silent! %s/\e\[[0-9:;]*m//g
  silent! %s/[^[:alnum:][:punct:][:space:]]//g
  silent! %s/\e\[[^\s]*\s//g
  " Remove empty spaces from end
  silent! %s/\s*$//
  let @/ = ""
  " Map q to force quit
  cnoremap q q!
endfunction

command! AnsiEsc call DeleteAnsiColorCodes()
