My experiments generate several log files, which I sometimes monitor manually. Some of the log files have an error message in the last line.

I want to open all log files with the cursor located at the last line. One solution can be

vim file1.log:128 file2.log:277

with last line numbers 128 and 277 determined by some wrapper code.

Is there a simpler solution?

  • Would it work to generate a quickfix list and use -q
    – D. Ben Knoble
    Oct 1, 2019 at 17:36

1 Answer 1


You can use

vim *.log +'argdo norm! G'


The + [cmd] allows you to run an ex command when you start vim and the command argdo norm! G will run norm! G on all the files being opened.

Of course you can replace *.log by the list of files you want to open.

EDIT to address the comments:

:h :$ being a valid ex commands norm! G can be replaced by $ to save some keystrokes

vim *.log +'argdo $'

And if you invoke Vim with the -p parameter which opens every buffers in their own tab you can replace argdo by tabdo to have the command executed on every tab instead of every buffers.

  • 2
    Can change norm! G for a single $
    – Matt
    Oct 1, 2019 at 17:59
  • @Matt It depends on what you want to do, as :h norm says this commands allows you to write as an ex command a normal mode command. Which means that norm G is the equivalent of pressing G while you are in normal mode i.e. going to the last line of the file. If you use norm $ you will put your cursor at the end of the first line.
    – statox
    Oct 1, 2019 at 18:03
  • 2
    I mean only $ without norm. That's an Ex command itself.
    – Matt
    Oct 1, 2019 at 18:35
  • 2
    @filbranden If the command contains a single quote, you may be tempted to surround it with double quotes instead of single quotes. In a double-quoted string, bash and zsh may interpret the dollar sign as a reference to an environment variable name (this can happen for example if you try to run a global command whose last line specifier is $).
    – user938271
    Oct 1, 2019 at 20:56
  • 2
    @filbranden If you run a command consisting of only a line specifier, and if it's followed by another command separated by a bar, Vim seems to interpret the line specifier command as :p, so in addition to moving the cursor on the line, it also has the undesired effect of printing it (compare :$ vs :$|let var=0; both move the cursor, but the second one also prints the last line). To avoid this pitfall, you can use :exe (e.g. :exe '$'|let var=0).
    – user938271
    Oct 1, 2019 at 20:56

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.