Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've recently switched from Emacs to Vim, so this may just be me completely misunderstanding how Vim works.

I've opened a file in Vim and make some changes but don't save them. I then use :e otherfile to open a second file, and make some changes to that. Again, without saving the changes, I'd like to go back to the first buffer. I'm using :bn for that, but when I do I get E37: No write since last change .... If I do :bn! then I can change back to the first buffer. From the first buffer I can change back to the second buffer with a straight :bn, but I have to do :bn! to go from the second buffer to the first every time.

I've got set bufhidden=hide in my vimrc, but if I run :set bufhidden? in Vim I get bufhidden=. Is that the problem maybe?

Edit: I've narrowed the problem down a bit. In the first file, :set bufhidden? returns bufhidden=hide, but in the second file, it returns bufhidden=. What's up with that? Am I missing something fundamental about Vim buffers here?

Edit2: Ok, it seems like set bufhidden=hide only applies to the first buffer opened. It needs to be explicitly called in subsequent buffers. I must be completely missing the point here, because this doesn't seem useful.

share|improve this question
Do you still have the problem. Have you found how to solved the problem or considered accepting an answer that solves your problem (if any)? – Luis Alvarado Dec 5 '11 at 18:56

Ok, I was just being an idiot. I didn't want set bufhidden=hide in my vimrc - that's just for a single buffer. Now that I've changed it to set hidden everything works as I felt it should.

share|improve this answer
Could you add this as your accepted answer, since it worked for you? – James Jun 7 '11 at 16:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.