Skip to content

Instantly share code, notes, and snippets.

@joongh
Created May 24, 2018 02:09
Show Gist options
  • Save joongh/f670e4ac2770fa6d9255423a9fb85562 to your computer and use it in GitHub Desktop.
Save joongh/f670e4ac2770fa6d9255423a9fb85562 to your computer and use it in GitHub Desktop.
vimrc - Check file encoding before write and change it to what you want
func! Encode_euckr()
" Don't change to euc-kr for these file formats
if &ft =~ 'py\|robot\|yaml'
return
endif
if &fileencoding != "cp949" && &fileencoding != "euc-kr"
if confirm("File encoding is not euc-kr. Change it?", "&Yes\n&No", 1) == 1
set fileencoding=euc-kr
endif
endif
endfunc
autocmd BufWritePre * :call Encode_euckr()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment