I was using the solution posted by otokan for several years until it stopped working recently. I found a new solution posted at the following site:
There are two solutions posted at the above link:
Solution 1: In the file /usr/share/vim/vim80/defaults.vim, find the autocmd that enables this behavior, and comment it out. This autocmd looks as follows:
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid, when inside an event handler
" (happens when dropping a file on gvim) and for a commit message (it's
" likely a different one than last time).
autocmd BufReadPost *
\ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
\ | exe "normal! g`\""
\ | endif
On my system (Crux 3.5 Linux), the autocmd was actually in the file /usr/share/vim/defaults.vim (no "vim80" subdirectory), so you may need to search around under /usr/share/vim for the defaults.vim file that defines this autocmd.
Solution 2: Add the following line to your .vimrc file:
:augroup vimStartup | au! | augroup END
I am currently using solution 2.