Vim Tips Wiki
Register
We recommend that you log in before editing. This will allow other users to leave you a message about your edit, and will let you track edits via your Watchlist. Creating an account is quick and free.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 94: Line 94:
   
 
==Leaving modified buffers==
 
==Leaving modified buffers==
βˆ’
If Vim is running with its default settings, or in vi compatible mode, the <code>:buffer</code> command will not abandon the buffer until any changes have been written. There are a few ways this can be changed:
+
If Vim is running with its default settings, or in vi compatible mode, the <code>:buffer</code> command will not abandon the buffer until any changes have been written. There are three ways this can be changed.
 
*Append <code>!</code> to the command to force the current buffer to be hidden, despite being modified. For example, if buffer 1 is the current buffer and it has been modified, the command <code>:buffer! 2</code> (or <code>:b! 2</code>) would hide buffer 1 (keeping its changes), and display buffer 2.
 
*Append <code>!</code> to the command to force the current buffer to be hidden, despite being modified. For example, if buffer 1 is the current buffer and it has been modified, the command <code>:buffer! 2</code> (or <code>:b! 2</code>) would hide buffer 1 (keeping its changes), and display buffer 2.
 
*Set the ''hidden'' option (<code>:set hidden</code>) so any buffer can be hidden (keeping its changes) without first writing the buffer to a file. This affects all commands and all buffers.
 
*Set the ''hidden'' option (<code>:set hidden</code>) so any buffer can be hidden (keeping its changes) without first writing the buffer to a file. This affects all commands and all buffers.
βˆ’
*Set the ''confirm'' option (<code>:set confirm</code>) so that when you tell Vim to abandon a buffer but you have unsaved changes, Vim will ask you whether to save your changes first, abandon them, or cancel the action. The choices given do not seem to allow simply hiding the buffer as in the previous options.
 
 
*Set either the ''autowrite'' or the ''autowriteall'' options (<code>:set autowrite</code> or <code>:set autowriteall</code>) to automatically save any changes made to the buffer before it is hidden.
 
*Set either the ''autowrite'' or the ''autowriteall'' options (<code>:set autowrite</code> or <code>:set autowriteall</code>) to automatically save any changes made to the buffer before it is hidden.
   
Please note that all contributions to the Vim Tips Wiki are considered to be released under the CC-BY-SA
Cancel Editing help (opens in new window)