Vim: persistent undo

Learning Vim is an endless process. Even after using it for two decades I still keep discovering new settings, features, and plugins that significantly improve my productivity.

The other day I came across “Ask HN: Best things in your bash_profile/aliases?” thread, with plenty of tips and tricks. One particular comment highlighted a feature that I kind of heard about but never got to setting up – persistent undo.

It turns out that starting with Vim 7.3 you can preserve the undo history between editing sessions. Which means that you make changes to a file, save it, close it, and when you reopen it later, you can press ‘u’ to undo the changes you’ve done during the last edit.

In order to set this up, you first need to create a folder, where Vim will store the undo history files. For example:

$ mkdir ~/.vim/undodir

Then, you need tell Vim that you want to use persistent undo and where to store the files. Edit the .vimrc file and add the following:

set undofile
set undodir=~/.vim/undodir

As long as you are using Vim 7.3 or newer and the directory exists, your persistent undo history will work like a charm.

Read the rest of the thread for more tips on how to clean it up periodically, and how to further improve your experience with Vim’s undo, using plugins that help navigate the undo tree.

UK’s ICO Guide to GDPR

Information Commissioner’s Office (ICO) is the the UK’s independent authority set up to uphold information rights in the public interest, promoting openness by public bodies and data privacy for individuals.

They have published their own Guide to GDPR, which I find somewhat better than this one from the European Union.

Reading postmortems

Once in a while a seemingly straightforward article turns into a goldmine of links and resources. This happened to me today with this one – “Reading postmortems“.

Not only this article itself is a very nice roundup of common sources for system failures, but it also links to a couple of awesome references:

  • Simple Testing Can Prevent Most Critical Failures: An Analysis of Production Failures in Distributed Data-Intensive Systems. This is both a talk and a paper.
  • danluu/post-mortems – a GitHub repository with a collection of publicly available postmortems from a variety of organizations, like Google, Amazon, Facebook, NASA, GitHub, and more.

If you still have no idea what postmortem is, Wikipedia explains.

GraphViz dot: Format: “png” not recognized.

As I’ve mentioned many times, I’m a huge fan of GraphViz software suite in general, and the dot tool in particular. It’s super handy for generating graphs and diagrams out of plain text files.

Today though I came across a problem that I haven’t seen before. While trying to generate an updated PNG graph from a dot file that used to work just fine before, I got the following:

$ dot -Tpng source.dot -o destination.png 
Format: "png" not recognized. Use one of: canon cmap cmapx cmapx_np dot dot_json eps fig gv imap imap_np ismap json json0 mp pic plain plain-ext pov ps ps2 svg svgz tk vdx vml vmlz xdot xdot1.2 xdot1.4 xdot_json

That looks weird. I tried the same with a few other formats and none of them were working. A quick Google search around found the solution over at StackOverflow. All I had to do was:

$ sudo dot -c

After that, dot started working as always.