Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.
106 votes
Accepted

Open filename under cursor like gf, but in a new tab (or split)?

EDIT: Suggest nicely symmetric mappings for the vertical split case, since Vim by default has two mappings for the horizontal split case. There are several ways to edit the "file under cursor", and ...
user avatar
  • 3,119
33 votes

How do you open a new buffer in the current window?

The answer is to use :ene[w] Hah I should have looked at the help before! My first instinct was to try :e without any arguments. I looked at the help for this and a bit further down is :ene[w] ...
user avatar
  • 1,121
23 votes
Accepted

How do I reorder open tabs?

You can use the tabmove command. (:help tabmove will tell you all you need to know) The command takes two kind of parameters: A sign (+ or -) followed by a number: :tabmove +2 will move your tab of ...
user avatar
  • 45.9k
17 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 ...
user avatar
  • 2,221
16 votes
Accepted

Move existing window to existing tab

Though there are commands to move existing windows around in the current tab page (i.e. affect the window layout by rotating, resizing, and moving), there are no commands to move a window to another ...
user avatar
  • 16.6k
15 votes

What can I do with more tabs than fit in one (airline) tab-line?

This is an inherent issue with the tab metaphor and every solution introduces more problems: multiple lines are harder to parse and take up too much space, tab groups make it impossible to see what's ...
user avatar
  • 32.6k
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 ...
user avatar
  • 5,868
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 ...
user avatar
  • 45.9k
12 votes
Accepted

How can I open multiple tabs at once?

Given the problems & complexity in my other answer using the "built-in" way by modifying the argument list, I've added by own small function to do this: " Open multiple tabs at once fun! ...
user avatar
12 votes

How can I open multiple tabs at once?

As far as I know, the only built-in way to do this is: :args *.vim :tab all First, the :args will replace the argument list. The argument list lists the files you opened Vim with; so vim file1 file2 ...
user avatar
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 ...
user avatar
  • 1,470
11 votes

Open filename under cursor like gf, but in a new tab (or split)?

You can use bindings for this: opening in a new window (split): nnoremap gf <C-W>f vnoremap gf <C-W>f opening in a new tab: nnoremap gf <C-W>gf vnoremap gf <C-W>gf also you ...
user avatar
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 ...
user avatar
  • 10.3k
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 ...
user avatar
  • 45.9k
9 votes

How to bind a set of buffers to a tab?

Mhh, i did not find any plugin out there, but you could write it yourself. You need to learn vimscript for this. I just implemented the functionality that you can switch between buffers in a tab (no ...
user avatar
  • 331
8 votes

Moving a visual range to a new tabpage?

Persisted If you intend to persist the selected lines under a new filename (and it's complete lines), you can do: :'<,'>w new-name | '<,'>delete _ | tabedit # The '<,'> range is ...
user avatar
  • 16.6k
8 votes
Accepted

How do I make opening new tabs the default?

After some experimentation I've found this to be the best way; it should behave the same as vim -p: augroup open-tabs au! au VimEnter * ++nested if !&diff | tab all | tabfirst | endif ...
user avatar
8 votes
Accepted

How do I open a file to view in a new tab?

:tab <cmd> opens a tab where a <cmd> would have opened a window. :view doesn't open a window, so :tab view doesn't open a tab :-) See :help :tab. However, we also have the :sview command, ...
user avatar
8 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.
user avatar
  • 4,208
8 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 ...
user avatar
  • 7,992
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 ...
user avatar
  • 16.5k
7 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 ...
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 ...
user avatar
  • 15k
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 {...
user avatar
  • 16.5k
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' ...
user avatar
  • 27.4k
6 votes

What can I do with more tabs than fit in one (airline) tab-line?

Vim provides 3 concepts for working with multiple files: Buffers: one for each file you've opened. Windows/Splits: view multiple things at the same time. Tabs: For multiple sets of windows. Useful ...
user avatar
  • 2,818
6 votes
Accepted

Duplicate tab with windows

You can use :mksession with a specialized 'sessionoptions' to make this easier. :set sessionoptions=blank,help,folds,winsize,localoptions :mksession :tabnew :source Session.vim Using this technique ...
user avatar
6 votes

How to bind a set of buffers to a tab?

Buffers are global and there's nothing you can do about that except writing your own abstraction layer on top of tab pages, windows and buffers. philolo1's answer shows a reasonable approach to the ...
user avatar
  • 32.6k
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 ...
user avatar

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