Tip 39Manage Hidden Files

When a buffer has been modified, Vim gives it special treatment to ensure that we don’t accidentally quit the editor without saving our changes. Find out how to hide a modified buffer and how to handle hidden buffers when quitting Vim.

Run these commands in the shell to launch Vim:

=> $ cd code/files
=> $ ls
<= a.txt b.txt
=> $ vim *.txt
<= 2 files to edit

Let’s make a change to a.txt. We’ll just press Go to append a blank line at the end of the buffer. Without saving the changes, let’s examine the buffer list:

=> :ls
<= 1 %a + "a.txt" line 1
 2 "b.txt" line 0

The buffer representing a.txt is annotated with a + sign, which indicates that it has been modified. If we were to save the file now, the contents ...

Get Practical Vim, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.