Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to disable the feature in vim that remembers where I was, when I'm using vimdiff. the reason for this is simple I don't want to miss a change that has scrolled out of view.

I found a lot of documentation on mkview and loadview but nothing on how to disable them. does anyone know how to disable loadview.

one interesting part of this is that because the file it's being compared to may have extra code at the start it needs to match the starting position of whichever file is longer.

I've gotten half of the problem solved thanks to garyjohn.

if &diff
   au BuffWinEnter * 1

the remaining problem is when the file I"m comparing it to is taller so scrolling to the first line of my changed file does not display all the changes in the old file.

in concept what I need to do is

1.) detect if vim is in diff mode
2.) scroll to the first line of the new file
3.) switch panes to the old code
4.) scroll to the top of hte changed file
5.) switch back to the new file
share|improve this question

I'm not sure what feature you mean, but I think you mean the automatic jumping to the last cursor position described here:

:help last-position-jump

The autocommand that implements this feature is not part of Vim itself but is often added to /etc/vimrc or /usr/share/vim/vimrc by Linux distributions such as Fedora. If that's the feature you want to disable, one approach would be to add more conditions to that autocommand, perhaps

au BufReadPost *
\ if line("'\"") > 0 && line("'\::) <= line("$") && !&diff && (v:progname !~ "diff") |
\   exe "normal! g'\"" |
\ endif

Another approach would be to add a new autocommand to your ~/.vimrc to jump to the top of the file if you're in diff mode, e.g.,

au BufWinEnter * if &diff || (v:progname =~ "diff") | 1 | endif
share|improve this answer
thanks for the insight, sadly the code example with the if line threw errors on loading up vim, and I didn't notice the second code snipped did anything. – Fire Crow May 18 '12 at 17:29
I did get something to work see updated post – Fire Crow May 18 '12 at 17:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.