I have multiple file open in Vim. When i want to switch from one file to another Vim does not allow me to switch unless I save the file or quit. Is there a way such that I do not have to save everytime when I want to switch? Is this a problem with Vim or am I making a mistake? If that's the way Vim works can anyone tell me the logical reason?
Just add
set hidden
to your ~/.vimrc
. It makes it possible to have multiple unsaved files open at all times.
While you are at it, you should add this line as well:
set switchbuf=useopen,usetab
It forces Vim to jump to an already open buffer where it is (right there, in another split-window, in another tab) instead of "hiding" the current buffer to replace it with the target buffer. This is useful for quickfix-related jumps but also for :sb
.
These two lines are the key to use Vim's buffers efficiently.
Use :n!
. This will move to the next file, ignoring the changes and not saving them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With