18 votes

What is the difference between a tab, viewport, window, split and buffer?

A buffer is the in-memory text of a file. It may differ from the saved version of the file. A window is a view of a buffer. You can have two (or more) windows editing different parts of the same ...
Tom Hale's user avatar
  • 2,601
14 votes
Accepted

Duplicate buffer into new tab instead of moving it

I'm not sure but you could try :tab split (or the shorter version :tab sp). The :split command should duplicate the viewport displaying a.txt, while the :tab modifier should move this viewport into a ...
user9433424's user avatar
  • 6,118
13 votes

Open multiple files in tabs from Explore mode

From :h netrw-t: BROWSING WITH A NEW TAB netrw-t Normally one enters a file or directory using the <cr>. The "t" map allows one to open a new window holding the new directory ...
statox's user avatar
  • 49.3k
12 votes
Accepted

Reopen the most recently closed buffer

I played around with this a bit and the following seems to work for the cases I tested, including closing a window split and a tab with one window using :q. augroup bufclosetrack au! autocmd ...
John O'M.'s user avatar
  • 8,462
12 votes
Accepted

how to close tab and remove this file from buffers

:bd will do that. From the documentation: :[N]bd[elete][!] *:bd* *:bdel* *:bdelete* *E516* :bd[elete][!] [N] Unload buffer [N] (default: current buffer) and delete it from ...
fruglemonkey's user avatar
  • 1,530
11 votes

How can I open a buffer in a new tab leaving the current window and buffer intact?

:tab split will create a new tab displaying the current buffer, since :tab modifies any command that would normally create a split to instead create a tab page. If you want to override <C-w>T ...
jamessan's user avatar
  • 10.9k
11 votes
Accepted

Is it possible to open a tab in a window and not a window in a tab?

From :h tab-page-intro: A tab page holds one or more windows. You can easily switch between tab pages, so that you have several collections of windows to work on different things. Usually ...
statox's user avatar
  • 49.3k
9 votes

Reopen the most recently closed buffer

You can try CTRL-O, this will go to last cursor posision in jump list, even for closed buffers. This will even work from fresh vim instance, so you can open last file with that.
grodzik's user avatar
  • 4,518
8 votes
Accepted

Spread already open files into split view

Here are a bunch of helpful commands for you: To open every buffer in a horizontal split: :sball To open every buffer in a vertical split: :vert sball You can do the same thing with tabs, e.g, to ...
DJMcMayhem's user avatar
  • 17.4k
8 votes

How can I open a buffer in a new tab leaving the current window and buffer intact?

After some research I found a solution. If you are focused on the buffer/window: :tabe % This opens the current buffer in new tab and leaves the current window intact. why does it leave the old ...
the_velour_fog's user avatar
7 votes

Is it possible to open a tab in a window and not a window in a tab?

No you can't, here's why: Vim use multiple concepts to handle text files: Buffer: An in-memory version of a file. Editing a file will in fact edit the buffer before writing (i.e. saving) anything to ...
nobe4's user avatar
  • 15.9k
7 votes
Accepted

Is there a way to move n tabs forward?

As far as I'm aware, there is no default way to do this. I looked into the ex command tabnext, which accepts a count, but functions exactly the same as gt (that is, it moves to tab page {count}, not {...
DJMcMayhem's user avatar
  • 17.4k
7 votes
Accepted

How can I make sure all buffers end up as tab or force remaining buffers into tabs?

The documentation for this feature can be found at :help -p: Open N tab pages. If [N] is not given, one tab page is opened for every file given as argument. The maximum is set with 'tabpagemax' ...
Rich's user avatar
  • 31.3k
6 votes
Accepted

How to open a list of files into tabs with Tab-top-bar?

If you want to open the file under your cursor in a new tab your mapping would be: nnoremap <leader>gf :silent! execute "tabe " . expand('<cfile>') <bar> redraw!<CR> Your ...
statox's user avatar
  • 49.3k
6 votes
Accepted

Open a filename given by an external command

From :help backtick-expansion: *backtick-expansion* *`-expansion* On Unix and a few other systems you can also use backticks for the file name argument, for example: > :...
user9433424's user avatar
  • 6,118
6 votes
Accepted

How do I open multiple files from find each in a separate tab in vim?

vim -p `find . -name '*.txt'` Putting the find command between backticks executes find before running the full command and the results replace what's between the backticks. So before running the ...
Neaţu Ovidiu Gabriel's user avatar
6 votes

Limit buffer list to current tab

The following code will give you the file names for the current tab (if the buffer in a window is connected to a file): " Get the buffer numbers of all windows on the current tab let buffers = ...
Jürgen Krämer's user avatar
6 votes
Accepted

How to create a new tab or window from a buffer?

Create a new window from a buffer: :sb<N>(horizontally) or :vert sb<N>(vertically). Create a new tab from a buffer: :tab sb<N> or create a new window and then press <C-W&...
sdp's user avatar
  • 481
6 votes
Accepted

Cannot switch tabs when in terminal tab

(This answer pertains to neovim specifically. If you find anything conflicting with vim, let me know and I'll edit the answer.) :h term operates in a separate mode: the terminal model. It's somewhat ...
3N4N's user avatar
  • 5,544
5 votes
Accepted

How does one put currently open files into tabs?

You can use :tab ball to open remaining buffers from the buffer list in new tabs. However, if you have more buffers left, than your 'tabpagemax' option, the last tab will open split windows for the ...
Christian Brabandt's user avatar
5 votes

Move existing window to existing tab

The two commands defined below move all buffers from the right hand tab to the current tab and then close the right hand tab. Mtabsp moves them by splitting horizontally and Mtabvsp splits vertically. ...
evpo's user avatar
  • 151
5 votes

How do I open multiple files from find each in a separate tab in vim?

find "$PWD" -name '*.txt' -exec vim -p {} +
andorov's user avatar
  • 205
5 votes
Accepted

How can I drag a file onto MacVim and make it open in a split, not a new tab?

The "Open files from applications" preference in the General preference pane gives more options on how dropped files should open, in case tabs are not desired. See :h macvim-drag-n-drop. After ...
djjcast's user avatar
  • 911
5 votes

Retitling tab labels

You can use the 'tabline' setting for this. Here's an example adapted from :help setting-tabline: set tabline=%!MyTabLine() " Set the entire tabline function! MyTabLine() let s = '' for i in ...
Martin Tournoij's user avatar
5 votes

Navigate to tag in a new tab if not already opened, like `tab drop`?

Put this in your vimrc: map <C-]> :TabExpand 1<CR> command -nargs=1 TabExpand call HandleTabTagExpand( <f-args> ) let s:commentchar = """ function HandleTabTagExpand(tagnumber) ...
Tim's user avatar
  • 426
5 votes
Accepted

How to not close MacVim after the last tab is closed?

You seem to be looking for MacVim Preferences, and they are under the MenuBar entitled "MacVim". MacVim -> Preferences -> General There you'll find settings for what to do on startup, and after the ...
jubilatious1's user avatar
5 votes

How to create a new tab or window from a buffer?

While editing command line a "special" #n (see :h cmdline-special) is replaced with the n-th buffer name. Hence, all of the following work in Vim (:h 42): :edit #42 :split #42 :tabedit #42 And so on....
Matt's user avatar
  • 20.4k
5 votes

How to return from tab page mode to the normal one?

You can use the :tabonly command, to close all other tabpages at once. Note: technically you will still have a single tabpage open, even if the tablabel does not show up.
Christian Brabandt's user avatar
4 votes

How does one put currently open files into tabs?

And now for something completely different... It seems like you are using Vim's tabs as file proxies (aka 1 file == 1 tab). This is how most editors work. Vim on the other hand uses the same familiar ...
Peter Rincker's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible