Search code examples
vimmodeline

Can I configure Vim to go to the end of particular file?


I have a text file that I append some text to. I would like to configure Vim to go to the end of this particular file each time I open it.

How do I do this for a single file?


Solution

  • If you put the following line into your vimrc, it will move the cursor to the last line of your-file-name.txt when you open it:

    autocmd BufRead your-file-name.txt normal G
    

    It will not, however, leave you in insert mode. If you also want to start inserting when you read the file, you need a slightly more complicated line in your vimrc:

    autocmd BufRead your-file-name.txt execute "normal G$"|startinsert!