Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim - open new tab in buffer

Tags:

vim

I jsut switched from sublime text to vim and I'm trying to replicate sublime's tab view.

I usually have a vertical split opened with :vsp and each split I'd like to open new tabs. To do this I type in bufdo tab split but it opens a new tab over my split and not within the split.

How can I open the tab within the split?

Many thanks

like image 816
Spearfisher Avatar asked Sep 27 '14 09:09

Spearfisher


People also ask

How do I switch between buffers in vim?

Pressing Alt-F12 opens a window listing the buffers, and you can press Enter on a buffer name to go to that buffer. Or, press F12 (next) or Shift-F12 (previous) to cycle through the buffers.

How do I open a new tab in Nerdtree?

7 Answers. Show activity on this post. s will open the file currently under the cursor in a new vertically split window. Use t to open in a new tab.

How do I open a new tab in vim?

Opening a tab Probably the easiest to remember is to run the :tabnew command while in normal mode. This will open a new tab with an empty buffer. If you want to edit a file in the new tab, you can run :tabnew filename and Vim will load the file in the new tab.


2 Answers

To Open a tab, editing the current file's name you can use %, which acts as a macro for the current file:

:tabe %

To Open a new tab & show the current file's directory:

:Te or :tabe %:h

To move between opened tabs:

gt # Go to next tab
gT # Go to previous tab
like image 102
omsobliga Avatar answered Sep 20 '22 07:09

omsobliga


In Vim, each edited file corresponds to a buffer. These are displayed in windows. Multiple windows can be split. Multiple such an arrangements of window(s) can be switched to in tab pages (this is a more recent addition).

In this hierarchy, the tab pages are always "above" the windows, so there can only be one single tabline that structures the tab pages. (And it's always between the menu / window title and the windows.)

In Vim, working with window splits is preferred over tab pages. It's recommended to use the latter only to separate different workspaces / projects, etc. Vim is very powerful (and with a long heritage), so you cannot directly take over concepts seen in other editors.

like image 29
Ingo Karkat Avatar answered Sep 17 '22 07:09

Ingo Karkat