Start vi at the last line

autocompletecommand linevi

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?

Best Answer

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.