Is there a shortcut like o that ignores the E445

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












In many cases I have one spare window which contains garbage and when I am in my main window, I'd like to close all other (with <C-W>o), but I am getting E445 for those that are not saved.
Is there a relatively sort key combination that can close all other saved and not saved windows?










share|improve this question







New contributor




John is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • Try :set hidden
    – Christian Brabandt
    3 hours ago










  • Thanks, but I am looking for key combination that I will use only in some cases, not always.
    – John
    3 hours ago














up vote
2
down vote

favorite












In many cases I have one spare window which contains garbage and when I am in my main window, I'd like to close all other (with <C-W>o), but I am getting E445 for those that are not saved.
Is there a relatively sort key combination that can close all other saved and not saved windows?










share|improve this question







New contributor




John is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • Try :set hidden
    – Christian Brabandt
    3 hours ago










  • Thanks, but I am looking for key combination that I will use only in some cases, not always.
    – John
    3 hours ago












up vote
2
down vote

favorite









up vote
2
down vote

favorite











In many cases I have one spare window which contains garbage and when I am in my main window, I'd like to close all other (with <C-W>o), but I am getting E445 for those that are not saved.
Is there a relatively sort key combination that can close all other saved and not saved windows?










share|improve this question







New contributor




John is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











In many cases I have one spare window which contains garbage and when I am in my main window, I'd like to close all other (with <C-W>o), but I am getting E445 for those that are not saved.
Is there a relatively sort key combination that can close all other saved and not saved windows?







key-bindings






share|improve this question







New contributor




John is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




John is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




John is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 3 hours ago









John

111




111




New contributor




John is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





John is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






John is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • Try :set hidden
    – Christian Brabandt
    3 hours ago










  • Thanks, but I am looking for key combination that I will use only in some cases, not always.
    – John
    3 hours ago
















  • Try :set hidden
    – Christian Brabandt
    3 hours ago










  • Thanks, but I am looking for key combination that I will use only in some cases, not always.
    – John
    3 hours ago















Try :set hidden
– Christian Brabandt
3 hours ago




Try :set hidden
– Christian Brabandt
3 hours ago












Thanks, but I am looking for key combination that I will use only in some cases, not always.
– John
3 hours ago




Thanks, but I am looking for key combination that I will use only in some cases, not always.
– John
3 hours ago










1 Answer
1






active

oldest

votes

















up vote
3
down vote













If you want to dispose of the unpersisted buffers right away, you'd need to write a custom function that iterates over all visible buffers and :bdelete!s them.



However, I think it's better to postpone the problem until Vim is eventually closed. This behavior is built-in via the :help 'hidden' option.



If you don't want to set this permanently, you could just temporarily set it (I'm using the upper-case O key to avoid overriding the original mapping; you could also use the alternative <C-o>):



:nnoremap <C-w>O :set hidden<CR><C-w>o:set nohidden<CR>


That's ugly, we can use :wincmd to make a single, concatenated command-line:



:nnoremap <C-w>O :set hidden<Bar>wincmd o<Bar>set nohidden<CR>


But wait, there's a special :only command that does the same:



:nnoremap <C-w>O :set hidden<Bar>only<Bar>set nohidden<CR>


And reading the documentation, this takes an optional ! to force hiding without having to set the option. I think that's a winner:



:nnoremap <C-w>O :only!<CR>





share|improve this answer




















    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "599"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    John is a new contributor. Be nice, and check out our Code of Conduct.









     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fvi.stackexchange.com%2fquestions%2f17856%2fis-there-a-shortcut-like-c-wo-that-ignores-the-e445%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    3
    down vote













    If you want to dispose of the unpersisted buffers right away, you'd need to write a custom function that iterates over all visible buffers and :bdelete!s them.



    However, I think it's better to postpone the problem until Vim is eventually closed. This behavior is built-in via the :help 'hidden' option.



    If you don't want to set this permanently, you could just temporarily set it (I'm using the upper-case O key to avoid overriding the original mapping; you could also use the alternative <C-o>):



    :nnoremap <C-w>O :set hidden<CR><C-w>o:set nohidden<CR>


    That's ugly, we can use :wincmd to make a single, concatenated command-line:



    :nnoremap <C-w>O :set hidden<Bar>wincmd o<Bar>set nohidden<CR>


    But wait, there's a special :only command that does the same:



    :nnoremap <C-w>O :set hidden<Bar>only<Bar>set nohidden<CR>


    And reading the documentation, this takes an optional ! to force hiding without having to set the option. I think that's a winner:



    :nnoremap <C-w>O :only!<CR>





    share|improve this answer
























      up vote
      3
      down vote













      If you want to dispose of the unpersisted buffers right away, you'd need to write a custom function that iterates over all visible buffers and :bdelete!s them.



      However, I think it's better to postpone the problem until Vim is eventually closed. This behavior is built-in via the :help 'hidden' option.



      If you don't want to set this permanently, you could just temporarily set it (I'm using the upper-case O key to avoid overriding the original mapping; you could also use the alternative <C-o>):



      :nnoremap <C-w>O :set hidden<CR><C-w>o:set nohidden<CR>


      That's ugly, we can use :wincmd to make a single, concatenated command-line:



      :nnoremap <C-w>O :set hidden<Bar>wincmd o<Bar>set nohidden<CR>


      But wait, there's a special :only command that does the same:



      :nnoremap <C-w>O :set hidden<Bar>only<Bar>set nohidden<CR>


      And reading the documentation, this takes an optional ! to force hiding without having to set the option. I think that's a winner:



      :nnoremap <C-w>O :only!<CR>





      share|improve this answer






















        up vote
        3
        down vote










        up vote
        3
        down vote









        If you want to dispose of the unpersisted buffers right away, you'd need to write a custom function that iterates over all visible buffers and :bdelete!s them.



        However, I think it's better to postpone the problem until Vim is eventually closed. This behavior is built-in via the :help 'hidden' option.



        If you don't want to set this permanently, you could just temporarily set it (I'm using the upper-case O key to avoid overriding the original mapping; you could also use the alternative <C-o>):



        :nnoremap <C-w>O :set hidden<CR><C-w>o:set nohidden<CR>


        That's ugly, we can use :wincmd to make a single, concatenated command-line:



        :nnoremap <C-w>O :set hidden<Bar>wincmd o<Bar>set nohidden<CR>


        But wait, there's a special :only command that does the same:



        :nnoremap <C-w>O :set hidden<Bar>only<Bar>set nohidden<CR>


        And reading the documentation, this takes an optional ! to force hiding without having to set the option. I think that's a winner:



        :nnoremap <C-w>O :only!<CR>





        share|improve this answer












        If you want to dispose of the unpersisted buffers right away, you'd need to write a custom function that iterates over all visible buffers and :bdelete!s them.



        However, I think it's better to postpone the problem until Vim is eventually closed. This behavior is built-in via the :help 'hidden' option.



        If you don't want to set this permanently, you could just temporarily set it (I'm using the upper-case O key to avoid overriding the original mapping; you could also use the alternative <C-o>):



        :nnoremap <C-w>O :set hidden<CR><C-w>o:set nohidden<CR>


        That's ugly, we can use :wincmd to make a single, concatenated command-line:



        :nnoremap <C-w>O :set hidden<Bar>wincmd o<Bar>set nohidden<CR>


        But wait, there's a special :only command that does the same:



        :nnoremap <C-w>O :set hidden<Bar>only<Bar>set nohidden<CR>


        And reading the documentation, this takes an optional ! to force hiding without having to set the option. I think that's a winner:



        :nnoremap <C-w>O :only!<CR>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 1 hour ago









        Ingo Karkat

        11k2538




        11k2538




















            John is a new contributor. Be nice, and check out our Code of Conduct.









             

            draft saved


            draft discarded


















            John is a new contributor. Be nice, and check out our Code of Conduct.












            John is a new contributor. Be nice, and check out our Code of Conduct.











            John is a new contributor. Be nice, and check out our Code of Conduct.













             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fvi.stackexchange.com%2fquestions%2f17856%2fis-there-a-shortcut-like-c-wo-that-ignores-the-e445%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            What does second last employer means? [closed]

            List of Gilmore Girls characters

            Confectionery