Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems with Vim while switching between open files

Tags:

vim

ubuntu

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?

like image 683
Parth Shah Avatar asked Oct 05 '12 06:10

Parth Shah


2 Answers

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.

like image 159
romainl Avatar answered Nov 01 '22 08:11

romainl


Use :n!. This will move to the next file, ignoring the changes and not saving them.

like image 36
CrazyCasta Avatar answered Nov 01 '22 08:11

CrazyCasta