View Full Version : ePub and vim


kovidgoyal
10-18-2010, 11:14 PM
I just discovered that vim can open and edit files inside a zip file automatically, which of course means it can do the same for epub. Which is awesome :)

Add the following to your .vimrc:


au BufReadCmd *.epub call zip#Browse(expand("<amatch>"))

Terisa de morgan
10-19-2010, 03:04 AM
Thank you very much. vim is my text editor at PC, so it's very useful for me.

Jellby
10-19-2010, 05:36 AM
Great tip, thank you! :)

MrPLD
10-19-2010, 05:37 AM
Got to love the vim... I use gtk-vim a lot here, very nice spreading it all over large panels :)

charleski
10-19-2010, 11:53 AM
Does it rezip correctly so the epub validates? I know 7zip doesn't.

Jellby
10-19-2010, 12:09 PM
Does it rezip correctly so the epub validates? I know 7zip doesn't.

I just tried editing a valid ePUB (deleted some content from XHTML and CSS files), and it remains valid. I don't know which "options" it uses to rezip the files, though.

kovidgoyal
10-19-2010, 01:47 PM
On Unix it uses

zip -u

which will only affect the changed files.

cuthbert19
10-25-2010, 10:57 AM
Great tip, thanks Kovid!

opitzs
10-27-2010, 08:02 AM
Thank you very much, this really is handy!

mrjoeyman
07-06-2012, 05:49 PM
I just discovered that vim can open and edit files inside a zip file automatically, which of course means it can do the same for epub. Which is awesome :)

Add the following to your .vimrc:


au BufReadCmd *.epub call zip#Browse(expand("<amatch>"))


I get the message: "***error*** (zip#browse) unzip not available on your system" when I try to open an epub file.

I used note pad to insert: "au BufReadCmd *.epub call zip#Browse(expand("<amatch>"))" into my .vimrc file.

Any help? Thanks.

kovidgoyal
07-07-2012, 01:00 AM
vim can't find unzip on your system, you need to setup it up so that it can open zip files first, only then will this command work for .epub.

mrjoeyman
07-07-2012, 10:44 AM
umm....ok thanks. I thought that was what the amendment was for. Have a good day.

AlPe
07-07-2012, 11:17 AM
Thank you, Kovid.

Being a relative novice to Vim, I wrote a script to decompress an EPUB file, edit it with Vim and recompress it, but your way is much more convenient!

kovidgoyal
07-07-2012, 01:41 PM
FYI: calibre has such a script (which works for EPUB, HTMLZ and AZW3 files)

calibre-debug --tweak-book filename.epub

(Essentially it is the command line version of the calibre GUI Tweak Book feature)

AlPe
07-07-2012, 03:06 PM
Thank you for letting me know.

AZdave
07-10-2012, 04:46 PM
Thanks Kovid. that will be very useful.

Vim is neat.