Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between :q and :bd command when we have many buffers?

Tags:

vim

I'm a beginner in vim and I've a simple question.
What is the difference between :q and :bd command when we have many buffers ?

Thank you for your answers.

like image 346
Malek KARKI Avatar asked May 11 '14 10:05

Malek KARKI


People also ask

How do buffers work in Vim?

A buffer is a temporary space in the memory to store your opened file(s). Each time you open a file, Vim stores it in a buffer; if you open 5 files, you have 5 buffers. A buffer remains "opened" even if that file is not visible (the buffer is hidden).


1 Answers

:q quit current window.

  • only one window: quit vim.
  • if you have more windows opened (splits): it closes the current window without deleting the buffer. You can see the buffer by :ls

:bd (without argument) delete(unload) current buffer

  • only one window: delete the current buffer, but won't close the window (quit vim).
  • more splits: delete the current buffer, and close the current window split.

you can test it with :ls to monitor the buffer changes.

like image 138
Kent Avatar answered Oct 23 '22 13:10

Kent