1

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?

syntagma
  • 23,346
  • 16
  • 78
  • 134
  • I really don't see any point of configuring vim for this purpose as it can simply be accomplished by pressing `shift+g` in normal mode which will take you to the end of the file. Also by simply pressing `gg` (in normal mode) will take you to the start of the file. I think anyone has this much time to be able to press one or two key. – Prabhat Kumar Singh Jan 27 '15 at 11:54

2 Answers2

8

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!
René Nyffenegger
  • 39,402
  • 33
  • 158
  • 293
0

if you're on a linux or on mac, you can use "tail"

tail -f n20 filename.log

^ this will keep showing the new lines. the file will be showing the 20 last lines.

toshi
  • 556
  • 1
  • 4
  • 8