我可以将 Vim 配置为转到特定文件的末尾吗?

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

我有一个文本文件,我在其中附加了一些文本。我想将 Vim 配置为每次打开此特定文件时都转到末尾。

如何为单个文件执行此操作?

如果您将以下行放入您的 vimrc,它会在您打开它时将光标移动到 您的文件-name.txt 的最后一行:

autocmd BufRead your-file-name.txt normal G

但是,它不会让您处于插入模式。如果你也想在读取文件时开始插入,你需要在你的vimrc中稍微复杂一点的行:

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

如果您使用 linux 或 mac,您可以使用 "tail"

tail -f n20 filename.log

^ 这将继续显示新行。 该文件将显示最后 20 行。