Let Vim automatically save backup versions in RCS

Last edited

Automatic save a backup version in RCS when saving in Vim

Emacs offers a great transparent integration of RCS. Vim lacks this feature, however this can be solved with a great Vim script.

With the Vim script rcsvers.vim you can let Vim automagicly keep files under local revision control.

you can happily use RCS side by side your DVCS


The Revision Control System (RCS) manages multiple revisions of files. RCS automates the storing, retrieval, logging, identification, and merging of revisions. RCS is useful for text that is revised frequently, including source code, programs, documentation, graphics, papers, and form letters.

RCS was first developed by Walter F. Tichy at Purdue University in the early 1980s.

Yes, RCS is old. It is the foundation for other revision control systems like CVS. RCS works great - on a personal basis. It is less good for collaboration.

RCS works file-based. So your revision information is based on changes in files, and not f.e. directories.

Like many other GNU programs there is good documentation, see:

Goal of RCS version control backups from Vim

Why would you want to use this?

When you open a file in Vim, edit it and save it and close Vim, there is no way to get your original file back. With RCS you can choose to revert to an older version. So the use of RCS can help you from mistakes.

Another reason to use this, is that you can view diff's between versions.

RCS together with other revision control systems like Git

You use the Vim script rcsvers.vim to protect you from your own mistakes and to give you version control of your local files. But what if you work on projects where there is already a some VCS in place, like Git ? Then you will have double version management, one through RCS and one through your VCS.

Well, you could solve this either by directory dependend configuration of Vim or by don't care about this double revision control. I have choosen for the second option. The advantage of always having a automated version control is great enough and it don't hurts to use RCS and Git side by side.

When using the Vim script rcsvers.vim the RCS-files are default saved in a subdirectory RCS in your working directory. So you only have to add this to your Git-ignore file (or whatever other VCS you are using) and you can happily use RCS without interfering with your normal Git-workflow (or whatever).


To take advantage of this option, you have to do two things:

  • install RCS
  • install rcsvers.vim

On Debian, installing RCS is just a case of

apt-get install rcs

In order to install rcsvers.vim you need to download this script in save it into $HOME/.vim/plugin/

To take advantage of this option, you have to do two things:

You can find rcsvers.vim here:


To automagic backup your changes in RCS, add the following line to your .vimrc:

let g:rvSaveIfPreviousRCSFileExists = 0

Leader commands

Apart for the automatic saving your changes into RCS, rcsvers.vim lets you interact with RCS through Leader commands.

Leader commands in Vim are commands that are entered after the Leader key.

rcsvers.vim has the following Leader commands:

  • rlog: To access the saved revisions log. This lets you view the different versions.
  • older: Does a diff with the previous version
  • newer: Does a diff with the next version

Use RCS without Vim

You don't need to interact with RCS through Vim of course.

You can use the RCS commands directly.

co The co command retrieves a revision from the RCS file, also known as "checkout".


co -r1.1 <filename> 

Check out an older revision of a file, in this case version 1.1

rcsdiff The rcsdiff command runs diff to compare two revisions in an RCS file.


csdiff -r1.1 -r1.3 <filename>

Shows a diff between version 1.1 and version 1.3 of the file

rlog Displays information about RCS files


rlog <filename>

Shows which versions are available and some information about these versions.