tags:

views:

204

answers:

3

Is it possible to have VIM highlight the changed lines since the last save? I know it can be done with version control, but can it be done without? I do not want to use any version control system, because the code I work on does not have that.

I think UltraEdit has something like that.

A: 

if you're using CVS, Git or Subversion for your source files then this plugin script will do what you want: VIM svndiff

it probably wouldn't be too difficult to get it to work from a diff of a temp file instead (if it doesn't have that option already).

chillitom
A: 

You need a temporary file to compare against, and I'm not sure that Vim has one (it has a .swp file but I don't know how it could be exploited).

Anyway a (quirky) possibility could be to use the generic SCMdiff and write a commandline script that performs a diff between the current file and a .tmp version of it. You should also map a command that saves the .tmp file for the current version, maybe calling automatically each time you save.

UncleZeiv
+6  A: 

From here:

if !exists(":DiffOrig")
    command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
          \ | wincmd p | diffthis
endif

Then just do :DiffOrig et voila!

:help :DiffOrig
Al