Vim

What is the difference between tab and buffers in vim ? (tabnext/buffernext)

are you retarded?

rude

Buffers are essentiall just open files in Vim. It's easier to understand if you disregard Vim tabs at first and just think of
> tabs in other editors -> buffers in vim
In other editors, a tab and the file are conceptually the same thing. Your tab bar is your list of open files. But in vim, you want to be looking at your buffer list.
Resist the urge to try and use tabs in vim like you would normally. Use :ls and :b to switch around open files. Enable wildmenu or install a buffer switching plugin to make the experience a bit nicer.
Once you're used to buffers, then you can start to understand tabs. Tabs basically let you save arrangements of splits. In tab 1, you might have 2 horizontal splits with some files open and in tab 2 you have vertical splits with (possibly the same) files open. Tabs in Vim are closer to workspaces.

Eh why ? I just begin...

He just a guy useless i think if he say that, he doesn't know what he is, si u hyst begin with vim, it's the kind of guy who think he's a hacker when he use a cli command

Thank you for help, so a tab is like a tab in firefox, and a buffer is some windows opened in one tab ?

Other way around, you retard.

Oh cool just get out

rude

>so a tab is like a tab in firefox, and a buffer is some windows opened in one tab
Huh? Unless you have some kind of extension installed, tabs in Firefox are like most tabs: 1 tab = 1 page

I'll give an example:
If you open vim and do
:e foo
:e bar
:e baz

You now have 3 buffers, foo, bar, and baz open. :ls will show these files. Because we opened baz last, the baz buffer is open in the current window. If we do
:vert sb bar

This will open the bar buffer in a vertical split. If we make a new tab with :tabnew and do :b baz, baz will be loaded into this window. Doing gt to switch between the tabs lets us see the two "views" we made; one with bar and baz, and the other with baz. Foo is open in a buffer, but hidden as no window has it loaded.

It's a bit complicated to explain so try it out.

I use i3, so we can say tabs is one workspace like 1 to 10, and buffers are the windows opened in the workspace ? So i can open firefox, term, etc

buffers are memory boxes that contain the files you have opened in your vim session, even if you have closed them.

normally vim shows you only one buffer at a time. but with :bnext you can move to the next buffer - ie the next file in the list of the files you opened this session. Type :ls to list all your buffers.

Now, when you split a window into panes you basically tell vim that you wish to see more than one buffer at the same time.

Tabs in Vim, are just containers for your panes. So you can have one tab that has only one pane, and thus shows one buffer, and a second tab that can have three panes, and thus showing three buffers etc.

TL;DR Tabs contain panes, panes contain buffers, your buffers are all the files you touches this session.

Exactly i have tried and so as i understand, gt is for switch between tabs, i begin to understand,

How to switch between splitted windows ?
For open foo i use :ls ?

So i will try to map

map :bn
map :bp

To switch between buffers, but doesn't work

Kind of, yes. Although you can't have the same window open in multiple workspaces in i3.

A vim buffer/tab layout could be like this:
> buffers: index.html, thing.php, style.css, extras.css, config.txt
> tab 1: index.html and thing.php in vertical split
> tab 2: index.html and style.css in horizontal, extras.css in vertical
> tab 3: config.txt

You can close the single window in tab 3, which will close the tab but config.txt is still open but hidden as you didn't remove the buffer.

So i can't open the same file in differents tabs ?

And foo is on tab 2 so i need to be on tab 2 to open foo ?

First, use non-recursive maps

C-Tab won't work in a terminal. It should work in gvim though.
Personally I find doing
:b(first few characters)

to be more useful than cycling sequentially through my buffers.

To move between splits, do and then h,j,k or l. But I find this mapping more convenient:
nmap h
nmap j
nmap k
nmap l


You can have the same buffer open in as many places as you like. In that example, foo was hidden. You can do :b foo from anywhere to open it inside the currently focused window.

Ok so i replace nmap with nnoremap but doesn't work, don't know the difference

It's not a problem for the file to open the file in many buffers/tabs ? Because sometimes i have the error when i open vim with a .swp file

I try and when i edit one file in one buffer, he is edited anywhere in buffers/tabs

And how to move between splitteds windows ?

If you open a file in two instances of Vim then you will get problems with clashing .swp files. But opening a buffer in two windows of the same Vim is fine. Try this:
> open file in vim
> :vnew % (open the same buffer in a vsplit)
> make edits in one of the splits

>And how to move between splitteds windows ?

See

Kind of, but buffers are much more like windows on the i3 scratchpad

- The terminals are there, thus 'open'/'loaded'
- You don't see them, and they are not in any workspace
- You can move one to an empty workspace, which makes it a window (something you can actually see)
- You can add another one to that window, creating a 'split'

The terminology stems from a buffer as in C, a piece of memory to temporarily hold data. Vim does not really keep your file open, it just reads its contents and stores these in a buffer.
You can edit the contents of a buffer. To do so visually, you show/link this buffer's contents to a window.
When you are done, you press :w and vim replaces the contents of the file with the contents of the buffer.

Yeah i have answered too rapidly

Exactly, and it's not a problem for the tabs ?
Very nice for your help, what is :cwindow ?

You can do :h (anything) to read the docs on it

:cw :cwindow
:cw[indow] [height] Open the quickfix window when there are recognized
errors. If the window is already open and there are
no recognized errors, close the window.