Browsing tar files with Vim

Software

Houki isn’t sure why she’s in a tape archive

Here’s a neat trick I learned today, entirely by accident. Say you were to open a tar file with Vim:

$ vim firewall-team.tar

You can view its contents and even edit the files inline!

" tar.vim version v26
" Browsing tarfile [..]/firewall-team.tar
" Select a file with cursor and press ENTER
firewall-team/
firewall-team/shinonono.houki
firewall-team/mizuno.ami
firewall-team/ayanami.rei
firewall-team/stadtfeld.kallen
firewall-team/littner.yoko

By comparison, nvi on FreeBSD and NetBSD will return fireworks. For certain times of the year this may be desirable, but may not be legal in certain juristictions. It’s also likely not what you’re after when browsing tar files.

firewall-team/^@^@^@^@^@^@^@^@^@^@^@^@^@^@
[..]

Emacs can also be used to read tar files, if your pinkie isn’t prone to repetitive stress injuries.

Author bio and support

Me!

Ruben Schade is a technical writer and infrastructure architect in Sydney, Australia who refers to himself in the third person. Hi!

The site is powered by Hugo, FreeBSD, and OpenZFS on OrionVM, everyone’s favourite bespoke cloud infrastructure provider.

If you found this post helpful or entertaining, you can shout me a coffee or send a comment. Thanks ☺️.