Maintain permissions bits when writing new file with VIM

You could do something like this. First, capture the name of the original file.

au BufRead * let b:oldfile = expand("<afile>")

Then, when you save the new file, change its permissions to be the same as those of the original file.

au BufWritePost * if exists("b:oldfile") | let b:newfile = expand("<afile>") | if b:newfile != b:oldfile | echo system("chmod --reference=".b:oldfile." ".b:newfile) | endif |endif

Just put both of those autocommands into your ~/.vimrc.