"--------------------------------------------------------------------------- " Encoding: " " The automatic recognition of the character code. " When do not include Japanese, use encoding for fileencoding. function! ReCheck_FENC() abort "{{{ let l:is_multi_byte = search("[^\x01-\x7e]", 'n', 100, 100) if &fileencoding =~# 'iso-2022-jp' && !l:is_multi_byte let &fileencoding = &encoding endif endfunction"}}} autocmd MyAutoCmd BufReadPost * call ReCheck_FENC() " Default fileformat. set fileformat=unix " Automatic recognition of a new line cord. set fileformats=unix,dos,mac " Command group opening with a specific character code again."{{{ " In particular effective when I am garbled in a terminal. " Open in UTF-8 again. command! -bang -bar -complete=file -nargs=? Utf8 \ edit ++enc=utf-8 " Open in iso-2022-jp again. command! -bang -bar -complete=file -nargs=? Iso2022jp \ edit ++enc=iso-2022-jp " Open in Shift_JIS again. command! -bang -bar -complete=file -nargs=? Cp932 \ edit ++enc=cp932 " Open in EUC-jp again. command! -bang -bar -complete=file -nargs=? Euc \ edit ++enc=euc-jp " Open in UTF-16 again. command! -bang -bar -complete=file -nargs=? Utf16 \ edit ++enc=ucs-2le " Open in UTF-16BE again. command! -bang -bar -complete=file -nargs=? Utf16be \ edit ++enc=ucs-2 " Aliases. command! -bang -bar -complete=file -nargs=? Jis Iso2022jp command! -bang -bar -complete=file -nargs=? Sjis Cp932 command! -bang -bar -complete=file -nargs=? Unicode Utf16 "}}} " Tried to make a file note version."{{{ " Don't save it because dangerous. command! WUtf8 setlocal fenc=utf-8 command! WIso2022jp setlocal fenc=iso-2022-jp command! WCp932 setlocal fenc=cp932 command! WEuc setlocal fenc=euc-jp command! WUtf16 setlocal fenc=ucs-2le command! WUtf16be setlocal fenc=ucs-2 " Aliases. command! WJis WIso2022jp command! WSjis WCp932 command! WUnicode WUtf16 "}}} " Appoint a line feed."{{{ command! -bang -complete=file -nargs=? WUnix \ write ++fileformat=unix | edit command! -bang -complete=file -nargs=? WDos \ write ++fileformat=dos | edit command! -bang -complete=file -nargs=? WMac \ write ++fileformat=mac | edit "}}}