Preserve modified time stamp after edit

timestampsvim

For files within a specific folder, I would like vim to never touch "modified"
timestamp at all.

The background is that I use Bloxsom for blogging, which uses plain text
files in ~/bloxsom as source of all articles. The article date (and therefore
order of appearence) is based on modification date of the text file. I don't
want article pop up like if it's new whenever I just fix a typo. (I do lots
of them… :D)

So far, vim changes timestamp and the original stamp is lost forever. This is
OK and I want to keep it that way for most of files on the system. But I don't
want that for the blog files – I can always touch the file if I need.

Any ideas on how to tweak vim into this behavior?

Best Answer

I don't think vim has this feature. One alternative is to modify a copy and set timestamp appropriately, e.g.:

cp -p post temp
vim temp
touch -r post temp
cp -p temp post

Or even better:

touch -r post timestamp
vim post
touch -r timestamp post
Related Question