Re: changed-yet-not-saved-lines highlighting feature
On 8/11/06, Gary Johnson [EMAIL PROTECTED] wrote: On 2006-08-10, Eddy Zhao [EMAIL PROTECTED] wrote: Hi, Very often, I open a lot of files to edit. When I exiting vim, vim prompt me to save every file which contain changes not saved yet. So, - Is there plugin that could highlight the changed-yet-not-saved-lines (possibly with yellow background), so that I could easily locate and check those changes and decide whether to save it or not. - Furthermore, is there plugin that could highlight the changed-and-saved-lines in a vim session in the file (possibly with green background), so that I could easily audit all changes of a file in a vim edit session. This command was posted by Piet Delport a few years ago. I use it all the time. command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis | wincmd p | diffthis This deserves to be put into vim.org/tips Yakov
Re: changed-yet-not-saved-lines highlighting feature
Hi Gary, On Fri, 11 Aug 2006 13:20:15 -0700 Gary Johnson [EMAIL PROTECTED] wrote: On 2006-08-10, Eddy Zhao [EMAIL PROTECTED] wrote: Hi, Very often, I open a lot of files to edit. When I exiting vim, vim prompt me to save every file which contain changes not saved yet. So, - Is there plugin that could highlight the changed-yet-not-saved-lines (possibly with yellow background), so that I could easily locate and check those changes and decide whether to save it or not. - Furthermore, is there plugin that could highlight the changed-and-saved-lines in a vim session in the file (possibly with green background), so that I could easily audit all changes of a file in a vim edit session. This command was posted by Piet Delport a few years ago. I use it all the time. command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis | wincmd p | diffthis Gary I can see why you use this all the time. BRILLIANT! It should certainly be a tip on vim.org if it isn't already!! I just threw this in my .vimrc and I'll too be using it all the time. (I used :command! though (note the !)) thanks, -- Mark
Re: changed-yet-not-saved-lines highlighting feature
On 8/10/06, Eddy Zhao [EMAIL PROTECTED] wrote: Hi, Very often, I open a lot of files to edit. When I exiting vim, vim prompt me to save every file which contain changes not saved yet. So, - Is there plugin that could highlight the changed-yet-not-saved-lines (possibly with yellow background), so that I could easily locate and check those changes and decide whether to save it or not. - Furthermore, is there plugin that could highlight the changed-and-saved-lines in a vim session in the file (possibly with green background), so that I could easily audit all changes of a file in a vim edit session. BTW, this feature is borrowed from a commercial editor I tried sometime ago, and find very useful when editing a lot of source code files. You can invoke vimdff to see differences. That requires temp copying: 1. :!cp % %.orig :diffsplit %.orig or :vert diffsplit %.orig It would be more convenient if :vimslpit allowed diff of the current buffer with original file on disk directly, but as far as I can see it doesn't allow it, you need to copy the file. It's not that bad, can be assigned to a macro: :nmap F5 :!cp % %.origcr:vert diffsplit %.origcr 2. :w! %.tmp and invoke 'vimdiff file file.tmp' in the other window 3. Less sophisticated method of revewing the changes: :w !diff -u - % (NB you must have space between 'w' and '!'). It does not highlight any lines but it's simple an it let you review your changes. Yakov
Re: changed-yet-not-saved-lines highlighting feature
On Thu, Aug 10, 2006 at 11:02:50PM +0800, Eddy Zhao wrote: Hi, Very often, I open a lot of files to edit. When I exiting vim, vim prompt me to save every file which contain changes not saved yet. So, - Is there plugin that could highlight the changed-yet-not-saved-lines (possibly with yellow background), so that I could easily locate and check those changes and decide whether to save it or not. - Furthermore, is there plugin that could highlight the changed-and-saved-lines in a vim session in the file (possibly with green background), so that I could easily audit all changes of a file in a vim edit session. BTW, this feature is borrowed from a commercial editor I tried sometime ago, and find very useful when editing a lot of source code files. I would have proposed using the diff commands, too.. (See DiffWithFileOnDisk in my privious post.) Perhaps it would be better to save to tempname() because those files will be deleted automatically.. Another waay would be : do u until vim no longer shows the modified tag ;) u will also show you what you've done. Marc Weber
Re: changed-yet-not-saved-lines highlighting feature
On 8/10/06, Marc Weber [EMAIL PROTECTED] wrote: On Thu, Aug 10, 2006 at 11:02:50PM +0800, Eddy Zhao wrote: Hi, Very often, I open a lot of files to edit. When I exiting vim, vim prompt me to save every file which contain changes not saved yet. So, - Is there plugin that could highlight the changed-yet-not-saved-lines (possibly with yellow background), so that I could easily locate and check those changes and decide whether to save it or not. - Furthermore, is there plugin that could highlight the changed-and-saved-lines in a vim session in the file (possibly with green background), so that I could easily audit all changes of a file in a vim edit session. BTW, this feature is borrowed from a commercial editor I tried sometime ago, and find very useful when editing a lot of source code files. I would have proposed using the diff commands, too.. (See DiffWithFileOnDisk in my privious post.) Perhaps it would be better to save to tempname() because those files will be deleted automatically.. I think Tim's method is better in that it doesn't require a file at all. Depending on personal preference, it might be better to explicitly make the diff buffer a scratch buffer, in something like the following: command! -nargs=0 ShowDifferences \ let ShowDifferencesOriginalBuffer=bufnr('%') \|execute 'bufdo diffoff' \|execute 'buffer' ShowDifferencesOriginalBuffer \|diffthis \|unlet ShowDifferencesOriginalBuffer \|below vert new \|set buftype=nofile noswapfile bufhidden=wipe \|r # \|1d \|diffthis There's a little extra there to clear diff mode from other buffers to avoid including more than the two intended buffers in the diff mode.