Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undo Close Tab in Vim

Tags:

vim

tabs

I close a tab in vim and immediately realize I need to re-open it again for something. Is there a way to undo close tab in Vim 7.2?

like image 383
Amjith Avatar asked Feb 21 '09 02:02

Amjith


People also ask

How do I close a tab in Vim?

You can type Ctrl-W c to close the current window. If that window is the last window visible in a tab, the tab is also closed (if another tab page is currently open).

How do I go to a specific tab in Vim?

In gnome-terminal, I can just press Alt + ( 1 , 2 , 3 , etc.) to switch to specific tabs. I can also use Ctrl + ( PgUp / PgDn ) to cycle through tabs (admittedly less convenient, but it can be remapped). If I want to use vim tabs instead of gnome-terminal tabs, typing :tabn and :tabp is quite cumbersome.


2 Answers

Your file is probably still open in a buffer:

:ls " get the buffer number :tabnew +Nbuf " where N is the buffer number 

To reopen buffer 18, for example:

:tabnew +18buf 
like image 141
greyfade Avatar answered Oct 16 '22 06:10

greyfade


:tabnew# 

Reopens recently closed file in new tab


Edit: Please use greyfade's answer. I don't like my answer, but I'm keeping it here for references and useful comment info.

like image 30
konyak Avatar answered Oct 16 '22 05:10

konyak