Fandom

Vim Tips Wiki

View NFO-files correctly

1,624pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Tip 1035 Printable Monobook Previous Next

created November 1, 2005 · complexity basic · author Carl Fürstenberg · version 6.0


Create an ftplugin for filetype *.nfo and include this line:

edit ++enc=cp437

cp850 might work, but some characters might be distorted then.

CommentsEdit

Your suggestion is quite useful for .NFO files. However, I use a different approach for similar problems, so for .NFO files, I am now using the following code in vimrc:

" Necessary for multiple encodings
set encoding=utf-8

" Common code for encodings
function! SetFileEncodings(encodings)
let b:myfileencodingsbak=&fileencodings
let &fileencodings=a:encodings
endfunction
function! RestoreFileEncodings()
let &fileencodings=b:myfileencodingsbak
unlet b:myfileencodingsbak
endfunction

" .NFO specific
au BufReadPre *.nfo call SetFileEncodings('cp437')|set ambiwidth=single
au BufReadPost *.nfo call RestoreFileEncodings()

Note that I use "set ambiwidth=single", since when dealing with Chinese I need to use "set ambiwidth=double".


Could be my version (6.1 i think), or just my tty... but i got errors with the end of the function call: "|set ambiwidth=single", removing this last bit worked fine.


"Create an ftplugin for filetype *.nfo"... uuhm.. like this:

/var/lib/vim/addons/ftdetect/nfo.vim:

au BufNewFile,BufRead *.nfo   set filetype=nfo

/var/lib/vim/addons/ftplugin/nfo.vim:

:silent edit ++enc=cp437

/var/lib/vim/addons/ is Debian/Ubuntu system-wide default vim scripts location, could also use /etc/vim/ or ~/.vim/ just create the ftdetect/ftplugin subfolders if they do not exist. :silent prevents the Press ENTER or type command to continue nag prompt because file gets converted twice and :set cmdheight=2 is not in your vimrc :)


Also on Fandom

Random Wiki