Many text files can be opened at once using

vim *txt

I know I can use :<int>n to move forward <int> files, but I don't know how to get to the last opened file. So far I've tried :1000n to intentionally overshoot but that gives the error

E165: Cannot go beyond last file

From there I just resort to a binary search trying to get to the end, which takes a while, i.e., :500n, :250n, 125n, ...

How can I get to the last opened file in vim?

  • 3
    :last is correct but if you want to know how many files were on the command line, you can use Ctrl-G in command mode
    – ChatterOne
    Aug 15, 2019 at 14:03

1 Answer 1


You can use :last.

See :help :last for more details. You might be interested in the other commands around it for managing files in :args as well.

Your Answer

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

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