diff options
author | xyz <gky44px1999@gmail.com> | 2021-07-29 11:14:26 -0700 |
---|---|---|
committer | xyz <gky44px1999@gmail.com> | 2021-07-29 11:14:26 -0700 |
commit | 2b15ba11d135e87f3db1b489e9f613305107aeec (patch) | |
tree | 54c58d5f6c39282e9f66d5dfcf12cab8fd7f8ca1 | |
parent | 4e31a0c1d1718832ba5afc57c9a78088a111c490 (diff) |
consider gO for autocmd change to utf-8 function
-rw-r--r-- | .config/nvim/init.vim | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index a4884e39..c76687b9 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -7,12 +7,15 @@ let fenc_bef = 0 " I use only one return for better readability function Autocmd_set_fenc() - let fenc_bef = &fileencoding - if &fileencoding != "utf-8" + " need to test &modifiable for gO + if &modifiable && (&fileencoding != "utf-8") + let l:fenc_bef = &fileencoding setlocal fileencoding=utf-8 unsilent echom ":w to rewrite as utf-8" + return l:fenc_bef + else + return &fileencoding endif - return fenc_bef endfunction " not fully understood augroup, recommanded in :help |