Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the meaning of the terms "buffer" and "window" in vim?

Tags:

vim

Hi I'm new to vim and I don't know what buffers and windows are. I can't find any tutorials on how to understand these two, so here are my questions:

  1. What is a buffer and how does it differ from a window?
  2. What can the buffer used for? and the window (I'm assuming it's for editing only)?
  3. Where can I find good tutorial on how to use buffers and windows?
like image 877
ruggedbuteducated Avatar asked May 14 '13 08:05

ruggedbuteducated


People also ask

What is the buffer in Vim?

Buffers in vim are the in-memory text of files. Your window is a viewport on a buffer. You can switch between open buffers, this is similar to tabs in other editors. Vim does have a concept of tabs too, but they are slightly different, read more about tabs in the Windows section.

What is buffer window?

A screen buffer is a two-dimensional array of character and color data for output in a console window. A console can have multiple screen buffers. The active screen buffer is the one that is displayed on the screen. The system creates a screen buffer whenever it creates a new console.

What is Vim window?

A Vim Window is what you see and interact with. A Window always shows a Buffer, being it from a file or just an empty one. Many windows can be opened at the same time by splitting the editor. Ctrl-w s , :split [filename] split the window, optionally opening a new file.

How do I close a window in Vim?

^Wc (or :close[!] ) closes the current window. If the hidden option is set and this is the last window referencing this file, Vim closes the window and the buffer is hidden. If this window is on a tab page and is the last window for that tab page, the window and the tab page are closed.


1 Answers

does this answer your question?

   A buffer is the in-memory text of a file.
   A window is a viewport on a buffer.
   A tab page is a collection of windows.

A window is a viewport onto a buffer.  You can use multiple windows on one
buffer, or several windows on different buffers.

A buffer is a file loaded into memory for editing.  The original file remains
unchanged until you write the buffer to the file.

I think the best tutorial is vim's help file.

EDIT

the above help info you could find by :help window

like image 196
Kent Avatar answered Sep 17 '22 23:09

Kent