I am new to vimscript so this is probably and easy one. I know of the update command which is like write except it only writes if there have been changes made. I would like to have something like
if ( update )
call expensiveOperation()
where the expensive operation is only called if update actually did something. But, I’m not familiar enough with vim to know how to do this. How can this be achieved?
Not directly, it is possible:
updatedoes some operation if&modifiedoption appears to be true (this option’s value is ignored when&buftypeis either “nofile” or “nowrite”). Hence you should do the following: