Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to highlight lines changed since the last save of a file in Vim?

Tags:

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.

like image 995
Ayman Avatar asked Aug 27 '09 11:08

Ayman


People also ask

How to highlight a line in vim?

With the default backslash leader key, pressing \l will highlight the line that currently contains the cursor. The mapping also sets mark l so you can type 'l to return to the highlighted line.

How do I go to a previous file in vi editor?

Since switching back to the previous file is something that tends to happen a lot, you don't have to move to the ex command line to do it. The vi command ^^ (the "control" key with the caret key) will do this for you. Using this command is the same as typing :e #.


2 Answers

Straight from Vim documentation (see :help :DiffOrig):

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

Then just do :DiffOrig et voila!

like image 124
DrAl Avatar answered Oct 01 '22 14:10

DrAl


From Vim Wiki:

Type :changes to display lines where changes occurred.

Use g; and g, to jump to changed lines.

like image 29
Peter M. - stands for Monica Avatar answered Oct 01 '22 14:10

Peter M. - stands for Monica