10

I'm new to vim.

I want to open vim from command line and have it scroll to the bottom of a file automatically.

The use case is opening logs.

Typically I open vim "vim log" and then scroll down using G. But I do this a lot. Does vim have a command line paramater to automatically scroll to the bottom like "vim -b log" ?

1 Answer 1

9

The following works for me:

vim log +$

The + bit tells vim to run a command after startup. The $ command moves to the last line in the file. Depending on your shell, you might need \ before the $ was to tell the shell to not treat the $ specially.

You can also put it before the file, which makes selecting from command history (e.g. up arrow in your shell) and modifying the filename easier, or making an alias:

vim +$ log

as an alias (using bash)

alias vimend="vim +$"

run like

prompt$ vimend /var/log/dmesg
2
  • 6
    The $ character isn't required if you just want to go to the last line, simply putting + on the command line is sufficient. Mar 1, 2016 at 4:48
  • @dash-tom-bang Agreed. In vim --help: + Start at end of file Aug 9, 2021 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.