Viming Safely

As I mentioned a couple of post ago, I started a new job in which I am doing more heavy development, and I am loving it. Now I am a very paranoid programmer and I am this way because I’ve destroyed hours of work with some poorly coded lines. As a result I typically backup the files I am working on before I edit them and this has saved me a few times. Couple this with the fact I am working in unfamiliar code of the new job and I find myself doing a quick ‘cp’ before every ‘vi’.

Something else about me, I am very lazy and I like to automate as much of my life as possible. With this, I created a nice little BASH function to handle this task for me.

It’s pretty basic and I add this to my .bash_profile. Now when I type ‘evim filename’, this little function will make a copy of the file in a Backup folder I defined before launching it with Vim. It will also add a time stamp as part of the backed up filename.