1

For me it's very annoying to have two functions to close window (:quit) or quit vim. I just want one command to close window and another command to quit vim. For example :q command to close window and :e to quit/exit vim. How to create these shortcuts in vim configuration?

  • 3
    In what practical case would you want to close all windows without leaving Vim? – nobe4 Aug 16 '16 at 13:16
  • 3
    Maybe you want :bd? – Nathan Wilson Aug 16 '16 at 13:25
  • 1
    @megas That is not what I asked, I try to understand what use you can have of closing all windows without closing Vim. – nobe4 Aug 16 '16 at 13:26
  • 3
    Vim always has at least one tab page, one window and one buffer. Closing all buffers is exactly the same thing as closing Vim. – romainl Aug 16 '16 at 14:18
  • 3
    Like the other commenters, I'm slightly unclear on what state you're attempting to achieve. After you have closed all the windows, what do you expect to see in your terminal? A new, empty buffer? The Vim start-up page? A giant window-sized statusline? Or are you expecting some new sort of "no window here" background? (Which, to be clear, is not something that exists in the current codebase.) Or are you just looking for the :qall command: to close Vim without manually closing each window one at a time? – Rich Aug 16 '16 at 15:31
1

Personally I very much dislike having to type out the entire word "close" - its smallest abbreviation is still :clo.

To solve this, I created the following command in my vimrc:

command -nargs=0 C :close

This means I have a nice, quick command :C which is very similar to :q but it only closes the current window, rather than quits. I use it all the time.

6

If it's windows you're after, use :close or ctrl-w c to close windows one by one (except the last one - it won't let you do it).

You also have :only to keep just the current window and close all others (or ctrl-w o).

The buffers, that's another story.

1

I just want one command to close window

  • :quit, or :quit! to abandon changes.

and another command to quit vim.

  • :qa, or :qa! to abandon ALL changes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.