How do I configure Vim to open a file at the last edited location?

Vim stores the cursor position of the last edited location for each buffer in the ‘”’ register. You can use the following autocmd in your .vimrc or .gvimrc file to open a file at the last edited location:

    au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") |

                         \ exe "normal! g`\"" | endif

Alternatively, you can simply source the vimrc_example.vim file, which is distributed with Vim.

Comments (1)


Pepsh Pepshinsky

Let’s see you to :help viminfo-file-name (option -i) :set viminfofile=NONE


Speak Your Mind