5

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" ?

5

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
  • The $ character isn't required if you just want to go to the last line, simply putting + on the command line is sufficient. – dash-tom-bang Mar 1 '16 at 4:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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