Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Vim, what is the "alternate file"?

Tags:

vim

I just ran :help registers in Vim and noticed that # 'contains the name of the alternate file'.

I have seen an example for renaming files that goes like this:

" Save the current file, foo.txt, as bar.txt :w bar.txt " Start editing bar.txt :e# 

So apparently in that case, the file you just saved out is the "alternate file."

Can someone give me a more general definition for the "alternate file" and what else you might use it for?

like image 257
Nathan Long Avatar asked Mar 03 '11 15:03

Nathan Long


1 Answers

The alternate file is the file that was last edited in the current window. Actually when you use some command to open a new buffer, if the buffer that was displayed had a filename associated with it, that filename is recorded as alternate file name.

See :help alternate-file.

like image 78
Benoit Avatar answered Sep 21 '22 15:09

Benoit