sponsor Vim development Vim logo Vim Book Ad

FencView.vim : Autodetect multiple encodings

 script karma  Rating 215/72, Downloaded by 4569

created by
Ming Bai
 
script type
utility
 
description
Usage:                                                            
              Commands:                                            
               :FencAutoDetect                                    
                   Auto detect the file encoding.                  
                   Built-in detected encodings:                    
                    Unicode:                                      
                       UTF-8                                      
                    Chinese Simplified:                            
                       CP936 (GBK, EUC-CN)                        
                    Chinese Traditional:                          
                       CP950 (Big5)                                
                       EUC-TW                                      
                    Japanese:                                      
                       CP932 (SJIS)                                
                       EUC-JP                                      
                    Korean:                                        
                       CP949 (EUC-KR)                              
               :FencView                                          
                   Open the encoding list window,                  
                   <up> and <down> to select an encoding,          
                   enter to reload the file                        
              Menu:                                                
                Select a file encoding from the                    
                Tools->Encoding menu just like what you do in      
                firefox/IE.                                        
              Options:                                            
                Set these value in vimrc to config this            
                plugin. Expmple:                                  
                let g:fencview_autodetect = 1                      
                                                                  
                "$FENCVIEW_TELLENC"                                
                  Now FencView allows the use of an external      
                  program to determine the file encoding. It      
                  may give you better performance, or better      
                  accuracy, in some cases. Set the environment    
                  variable FENCVIEW_TELLENC (or the vimrc          
                  variable $FENCVIEW_TELLENC) to use this          
                  feature. It is currently tested against          
                  tellenc.                                        
                  (default: 'tellenc')                            
                  It means if tellenc is executable, it will      
                  be used by default. If you still want to use    
                  the detection mechanism of this script, set      
                  the value to "fencview".                        
                                                                  
                "g:fencview_autodetect"                            
                  Auto detect file encoding when you open a        
                  file.                                            
                  (default: 1)                                    
                                                                  
                "g:fencview_auto_patterns"                        
                  Set this variable in your vimrc to decide        
                  the pattern of file names to enable              
                  autodetection.                                  
                  (default: '*.txt,*.htm{l\=}')                    
                                                                  
                "g:fencview_checklines"                            
                  It checks first and last several lines of        
                  current file, so don't set the value too        
                  large.                                          
                  (default: 10)                                    
                                                                  
Tip:          1 "+iconv" feature is needed. If you are            
                using Microsoft Windows, make sure you            
                have iconv.dll in $PATH.                          
                (http://mbbill.googlepages.com/iconv.dll)          
                Use command ":echo has('iconv')" to check it.      
              2 Make sure there is no modeline at the end of      
                current file.                                      
              3 set encoding to utf-8 for better performance.      
              4 No effect to Vim encrypted files.                  
                                                                  
 
install details
Copy FencView.vim to your plugin directory.

You may want to try an external tellenc. One such program is available at http://wyw.dcweb.cn/download.asp?path=&file=tellenc.zip.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
fencview.vim 4.6 2008-12-11 7.0 Ming Bai Progress bar no longer used for better compatibility; one may use  g:fencview_checklines=0 to check all lines; do not change the current file encoding if no valid multi-byte encoding is detected.
fencview.vim 4.5 2008-09-05 7.0 Ming Bai Add a workaround (UNIX only) for earlier Vim versions where shellescape() is not defined; avoid using `y$' to prevent issues when folding is used (contributed by Ingo Karkat).
fencview.vim 4.4 2008-06-02 7.0 Ming Bai Fix two problems found under Unix:
1) Big5 can be loosely used for CP950;
2) g:legacy_encoding can be wrongly guessed (it should not be used).
fencview.vim 4.3 2007-11-27 7.0 Ming Bai Make it run more smoothly under Windows with my gVim build (http://wyw.dcweb.cn/#download).
fencview.vim 4.2 2007-05-25 7.0 Ming Bai update
fencview.vim 4.1 2007-05-22 7.0 Ming Bai some improvements
fencview.vim 4.0 2007-05-03 7.0 Ming Bai It merges functionality in multienc.vim: allows the use of an external program to determine the file encoding; use the http-equiv meta tag to help decide the file encoding; use the fileencoding modeline to help decide the file encoding; autodetect the encoding of .txt, .htm, and .html files; add a new command FencManualEncoding to override the encoding where autodetection affects the normal ++enc. Also some minor fixes are made.
fencview.vim 3.2 2007-03-04 7.0 Ming Bai bug fix: set syntax on after auto detect
fencview.vim 3.1 2006-12-11 7.0 Ming Bai A lot of improvements.
fencview.vim 2.3 2006-11-28 7.0 Ming Bai Now it can auto detect the file encodings. You just need to select "Auto detect" from the menu or use :FencAutoDetect command to let it detect the fileencoding automatically.
Supported encodings:
utf-8
cp936(GBK)
cp950(big5)
cp932(sjis)
fencview.vim 1.2 2006-11-16 7.0 Ming Bai Some bug fix.
fencview.vim 1.1 2006-11-15 6.0 Ming Bai Now, you can select a file encoding from the menu, just like what you did in Firefox/IE.
Screenshot:
http://mbbill.googlepages.com/fenc.png
fencview.vim 1.0 2006-11-14 7.0 Ming Bai Initial upload

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo