Wouldn’t it be nice if you could view an old version of a file side by side with the current one in Vim? And it would scroll together? And syntax highlight?
Well, open the current file in a Vim window. Then do the following:
- Open a new (blank) split or window:
- Dump the old file contents in this new buffer: (note: ‘!’ executes a shell command, and ‘read’ puts it in the current buffer)
:read !git show HEAD^:path/to/file/from/root.py
- Set the right syntax highlighting:
- Scroll bind the two splits: (note: you must run this command in both splits)
Hope this helps. Let me know if there’s a better way to do this.