Vim diff opens 2 files for diffing, but it doesn't navigate to the first diff section automatically on startup. Can I add something to startup script (like _vimrc) to do this?
1 Answer
]c
doesn't jump to the first difference, it jumps to the next difference. If your first difference is on the first line, ]c
would jump to the the second one which is not what you want. One could work around that with ]c[c
(jump to next difference then jump to previous).
This command:
$ vim -d -c 'norm ]c[c' filea fileb
seems to do what you want.
I don't think it is necessarily a good idea to put that in your startup sciript.
-
1You could put that as an autocommand only when
'diff'
is on, I suppose. That seems harmless enough...:help vimdiff
gives an example of how (if &diff
)– derobertJun 9, 2015 at 17:21
]c
does.