Problem:
I have .glabels
generated files, which are gzipped xml. When I rename file to have suffix .xml.gz
, then VIM properly recognizes file and it's editable, human readable xml. After edit I have to rename back to original name.
What I try to open e.g. x.glabels
file without renaming, what happens is that I see binary data. It does not ungzipped it.
How to force Vim from command like to treat given file like .gz
?
If possible please make answer more general, to address general problem : how to make Vim , treat file .extension1
as file .another_extension
?
Use case:
http://glabels.org/ uses gzipped xml, so instead of .glabels
extension, they could use .xml.gz
.
When I rename file by adding .txt.gz
or .xml.gz
extension, VIM properly picks it up.
However with .glabels
extension it treats files like binary.
Question : How to force VIM from commandline to open given file (e.g. "x.glabels") like another type (e.g. "x.xml.gz") ?
No Answers: I know I can make symlink or temporarily rename file. I wonder about VIM flags.
Bonus Addition to answer:
You are welcome to include in your answer nice way of configuring VIM to treat e.g. .glabels
as .xml.gz
, but this won't be accepted as full answer, as I look for onliner that I can use on any machine I will have to deal with. Still, information about config might be helpful for other readers (or my main machines;) ).
filetype
? Please refine what you mean by "open as another file type"vim -c set filetype=xml.gz [filename]
when starting vim?:h zip-extension
:h new-filetype-scripts
would be enough :P