you could create a short "wrapper" script, e.g. "vicp.sh" :
vi vicp.sh
#!/bin/bash
# vicp.sh - created 2015-09-01 jm - wrapper script to copy files before and after edit
/usr/bin/cp $1 $1.before-`date +'%Y%m%d-%H%M'`
##################################################################################
# if desired, add an archive Directory path to copied file name, e.g.
# uncomment the following 2 lines and comment out the line above this comment
# mkdir BAK
# /usr/bin/cp $1 BAK/$1.before-`date +'%Y%m%d-%H%M'`
##################################################################################
/usr/bin/vi $1
/usr/bin/cp $1 $1.after-`date +'%Y%m%d-%H%M'`
##################################################################################
# if desired, add an archive Directory path to copied file name, e.g.
# uncomment the following 2 lines and comment out the line above this comment
# /usr/bin/cp $1 BAK/$1.after-`date +'%Y%m%d-%H%M'`
##################################################################################
/usr/bin/ls -l $1*
/usr/bin/ls -l BAK/$1*
make it executable and put it in your "bin" directory:
------------------------------------------------
--> chmod 744 vicp.sh
------------------------------------------------
--> which vicp.sh
/home/luser/bin/vicp.sh
------------------------------------------------
(you could also drop the .sh, so you'd only have to type: vicp filename )
EXAMPLE:
--> vicp dead.letter
-rw------- 1 luser users 324 Sep 1 15:39 dead.letter
-rw------- 1 luser users 324 Sep 1 15:39 dead.letter.after-20150901-1539
-rw------- 1 luser users 325 Sep 1 15:39 dead.letter.before-20150901-1539
copy below, and paste into a new file, save as vicp (or vicp.sh):
uncomment BAK versions and comment out the plain versions
#!/bin/bash
# vicp.sh - created 2015-09-01 jm - wrapper script to copy files before and after edit
##################################################################################
# define variables (if your shell does not recognize the variables, export them)
CP="/usr/bin/cp" # change path if which shows /bin/cp
VI="/usr/bin/vi" # change path if which shows /bin/vi
LS="/usr/bin/ls -l" # change path if which shows /bin/ls
DATE="/usr/bin/date" # change path if which shows /bin/date
MKD="/usr/bin/mkdir" # change path if which shows /bin/mkdir
##########################################################################################
## remove comments on the following lines to make a local directory for archived copies
# $MKD BAK
# $CP $1 BAK/$1.before-`$DATE +'%Y%m%d-%H%M'` # remove first comment to copy to BAK dir
# $VI $1
# $CP $1 BAK/$1.after-`$DATE +'%Y%m%d-%H%M'` # remove first comment to copy to BAK dir
# $LS BAK/$1*
##########################################################################################
## add comments on the following lines if you use the BAK directory for local archives
$CP $1 $1.before-`$DATE +'%Y%m%d-%H%M'` # add a comment if you only want to copy to BAK
$VI $1
$CP $1 $1.after-`$DATE +'%Y%m%d-%H%M'` # add a comment if you only want to copy to BAK
$LS $1*
$LS BAK/$1*
##################################################################################
|