-   Linux - Software (
-   -   Vim - How can I stop :bn and :bp from saying "No write since last change"? (

OR13 10-08-2010 11:48 AM

Vim - How can I stop :bn and :bp from saying "No write since last change"?
Hello all,

I'm using vim quite extensively for editing code segments.
Two of the most common commands I use are :bn (next buffer) and :bp (previous buffer).

However, using :bn, navigating away from a file I'm editing, shows the message "No write since last change (add ! to override)", and only :bn! or :w and then :bn works.

I know there's a way to stop this from happening - probably something in the .vimrc file...
Does anyone know what I can do?


penguiniator 10-08-2010 01:27 PM

set autowrite
set autowriteall

Either of those will eliminate the problem.

OR13 05-07-2011 05:21 AM

I used this way (autowrite) for a few months,
but it wasn't perfect for me - because when working with code (especially scripting languages such as python), saving open buffers in mid-work is dangerous (for example, if I have a cron that runs my code, and I'm in the middle of editing it, I might get syntax errors, name errors, etc.).

Now I've found a far better option, for me:
:set hidden (Saves all open buffers in the background, instead of closing them and re-opening on demand)
in conjunction with (the default, on my machine at-least):
:set confirm (Demands confirmation before closing unsaved buffers)
Credit must be given to all the commentators here.

Hope this helps others... :)

All times are GMT -5. The time now is 12:28 AM.