:up
To write (save) the current file only if the file has been modified you can use
the ex commands :up r :update.
The difference between this command and :w is that :w will write the file even
if it has not been modified. This command is also similar to :x, :xit, :exit,
and :exi, but will not quit the window after writing the file.