I often find myself editing one of a set of configuration files by adding lines at the end. For editing I use vi (from bash) and currently use:

vi +$(wc -c /home/john/master/tried.cfg)

The above works, but it makes filename completion with Tab impossible, which is a nuisance when changing the filenames after scrolling back on the commandline.

Is there an easier way to do go to the last line of the opened file? Maybe with the +{} commandline option that vi offers. Or is there some way to make commandline completion in the $() work?

  • 3
    try vi +$ filename Aug 16, 2015 at 7:00
  • I had to try out your command to see how it worked. DId not realise immediately that wc -c echoes the filename as well as the word count.
    – Anthon
    Aug 16, 2015 at 8:34
  • Pressing G after opening vi is another approach
    – steve
    Aug 16, 2015 at 14:33

1 Answer 1


You can use

vi +$ /home/john/master/tried.cfg

and do a way with the $() part completely. You don't have to escape the $ as it is followed by a space and bash doesn't expand it.

You can also use this to go to, e.g. the one before last line:

vi +\$-1 /home/john/master/tried.cfg

but then you have to escape the $ with a backslash.

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.