56

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 while you certainly can remap gf to edit in a new tabpage as @alexander-myshov mentions, that means you have two ways to edit it in a new tabpage, but no way to ...


23

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] Edit a new, unnamed buffer. This fails when changes have been made to the current buffer, unless 'hidden' is set or 'autowriteall' is set and the file can be ...


18

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 2 places to the right :tabmove -2 will do the same to the left. You can also use the command with a simple number to set the position of the tab: :tabmove 0 ...


13

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 in them at a glance and thus defeat the whole purpose of having a tab-line, arrows to scroll the tab-line are also very impractical and contrary to the purpose ...


13

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 buffer. A viewport is synonymous with a window. A tab page contains one or more windows. You can see what windows are in which tab with :tabs. A split is where ...


12

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 dedicated tab page. If you want to change the behavior of C-w T, you could remap it like this: nnoremap <C-w>T :tab split<CR> More generally, ...


11

: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 the buffer list. If the buffer was changed, this fails, unless when [!] is specified, in which case changes are lost. The file remains ...


11

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 you will see a list of labels at the top of the Vim window, one for each tab page. Tabs containing windows is the way Vim was designed to work. I think you ...


10

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 tab. As a window is just a viewport into a loaded buffer, you have to: Note the buffer number displayed in the current window. :close! the window. Switch to ...


10

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! OpenMultipleTabs(pattern_list) for p in a:pattern_list for c in glob(l:p, 0, 1) execute 'tabedit ' . l:c endfor endfor endfun ...


9

: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 to do that instead of its default behavior, you can remap it. nnoremap <silent> <C-w>T :tab split<CR> You may be wondering why I used :tab ...


8

: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, which does: Same as ":split", but set 'readonly' option for this buffer. This does open a window. So :tab sview file opens a tab. :sview is short for "...


8

Just 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 check this: :help CTRL-W_gf


8

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 inserted automatically when you enter command-line mode from visual mode. :write can take a range, and afterwards, the filename is accessible via the alternate ...


7

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 deletion yet). You can copy this into your vimrc: if !exists("g:WindowBufManager") let g:WindowBufManager= {} endif function! StoreBufTab() if !has_key(g:...


7

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 open every buffer into its own tab: :bufdo tab split If you would like more control over how they get split, you can do this individually. First, list every ...


7

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 the file on your filesystem. Window: A view into a buffer, a representation of the buffer content. A window can switch buffer and split to display multiple ...


7

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 listing or file in a new tab. So in the netrw window simply press t when your cursor is on the file or on the directory you want to open in the new tab. To do ...


6

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 means that the argument list contains file1 and file2. We can modify this at runtime, and Vim will open a buffer for every new entry in the argument list. See ...


6

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 problem but you'll quickly find the limits of such a "solution" and need to duplicate a lot of built-in features like :bufdo or the alternate file… "Arguments" ...


6

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 we can create an easy to use command. Put the following command in your vimrc: command! -bar DuplicateTabpane \ let s:sessionoptions = &...


6

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 buffer intact when <C-w>T destroys it? I guess its because tabe generally creates a new tab, whereas <C-w>T seems to create a new tab and move the ...


6

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: > :next `find . -name ver\\*.c -print` :view `ls -t *.patch \| head -n1` The backslashes before the star are required to prevent the shell from expanding "ver*.c"...


6

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 mapping didn't work because shellescape only escapes some characters in the string it get as arguments, what you need is expand to convert <cfile> to its ...


6

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 {count} pages forward): :tabn[ext] {count} {count}<C-PageDown> {count}gt Go to tab page {count}. The first tab page has number one. However, this isn'...


6

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' pages (default 10). (emphasis mine) So to increase the number of tab pages, add a line to your .vimrc, e.g.: set tabpagemax=20 If you don't want to change ...


5

The :o command does something completely different, where tabs wouldn't really make sense: This command is in Vi, but Vim only simulates it: *:o* *:op* *:open* :[range]o[pen] Works like |:visual|: end Ex mode. {Vi: start editing in open mode} :[range]o[pen] /...


5

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 for managing multiple tasks. By conflating them all into the same thing, you're losing out on a lot of power. You should consider other ways which you can use ...


5

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 remaining ones. Perhaps this works better: :set tabpagemax=99 :tab ball or even :exe "tab ball" &tabpagemax


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