tags:

views:

122

answers:

1

I often have multiple viewports opened in vim, using the :vsp and :sp commands. After I've been editing for a while, I'll often run the :make command from within vim. When I get errors, vim will then show me the lines that gcc says caused my errors. However, vim will often open the file with errors in another viewport, even if that file is already open. An Example:

Before Make

--------------------
|         |        |
| file 1  | file 2 |
|         |        |
|         |        |
--------------------

Ok, assume there are errors in file 2

--------------------
|         |        |
| file 2  | file 2 |
|         |        |
|         |        |
--------------------

vim now jumps to the error line in the left viewport, even though the right viewport already had that file open.

Is there some way to tell vim not to use the file one viewport if the file that the error is in is already open in vim?

+2  A: 

Try setting the option switchbuf=useopen.

Nathan Kitchen
I'd also recommend switchbuf=usetab (it's the same as useopen but also looks for buffers in tabs).
spatz