Monday, February 6, 2012

Re: Determining whether :update actually saved file?

On Mon, Feb 06, 2012 at 08:13:21PM -0800, suan wrote:
> Is there a way to call :update <some other file name> such that you can
> tell whether there actually were changes and that the file was written?

> I'd like to perform an action each time the current buffer changes (without
> explicitly saving to the current file), but presently calling :update
> <other file name> seems like a black hole as there's no way to know whether
> anything was written or not.

> I've tried treating update as a function by doing things like `echo
> update`, but it seems that it behaves differently from a function and it
> errors...

it sounds as if you need a function that tests &modified --
something like

function! MySave()
if &modified
write some-other-name
echo 'i just wrote' some-other-name
endif
endfunction

hth,
sc

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: