Is it possible to diff or even vimdiff two very similar subroutines occurring in the same file? If so, how?
I can think of copying the two subroutines in two separate files and then diff them, but is there a way to do it within the original file?
You cannot do this within the original file, but you can do this without using separate files, only separate buffers. This should work if you copied one subroutine in register
a(for example, with"aytyped in Visual mode) and other subroutine in registerb:To automate:
Note that you may want to set
hiddenoption if Vim refuses to abandon changed file (see:h abandon).