Skip to content

Instantly share code, notes, and snippets.

@leemars
Created July 23, 2013 05:20
Show Gist options
  • Save leemars/6060036 to your computer and use it in GitHub Desktop.
Save leemars/6060036 to your computer and use it in GitHub Desktop.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Encoding
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set encoding=utf-8
set fileencodings=ucs-bom,utf-8,gbk,euc-jp,euc-kr,big5,gb18030,latin1
function! s:CheckGBLocale(locale_var)
let locale_var=toupper(a:locale_var)
if (match(locale_var, '.GBK$') != -1 || match(locale_var, '.GB18030$') != -1 || match(locale_var, '.GB2312$') != -1)
return 1
else
return 0
endif
endfunction
if (s:CheckGBLocale($LC_ALL) || s:CheckGBLocale($LC_CTYPE) || s:CheckGBLocale($LANG))
set termencoding=gb18030
else
set termencoding=
endif
" Set terminal encoding to GB18030
map <Leader>tg :set termencoding=gb18030<CR>
" Set terminal encoding to UTF-8, same as encoding option
map <Leader>tu :set termencoding=<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment