I'll show you three tips which can be incredibly useful, yet, they are very little known.
Running a command like:
$ vim archive.tar.gz
will open the
archive.tar.gz, and list the contents of the archive. From there, you can open, edit and save changes in these files, without the need to extract them first.
How cool is that? :)
Supported archives: tar.gz, tgz, zip, jar, etc.
Vim has the ability to edit files remotely, over the network. This feature comes with the netrw plugin. To achieve this,
netrw uses the SSH protocol, and manages remote files via the
Here's how to do it:
Note the double
/ for the directory on the remote host, which is needed to correctly resolve the absolute path.
[:port] is optional.
So with the command above you can open a file located on a remote host for editing.
What actually happens in the background is that Vim uses
scp to download the requested file from a remote machine to a local
/tmp directory, and then opens it for editing.
When you save your changes to the file, the changes are first applied to a local copy in
/tmp directory. After that, the file is uploaded via
scp to the remote host.
Did you know that you can open the last edited file on the machine with cursor on the latest location?
Just start Vim, hit
o - and there you go.
o and see what happens ;)
Now, if you wanna discover more Vim tips you've never heard of, take a look at my book Mastering Vim Quickly: From WTF to OMG in no time