Conditional window split

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











up vote
1
down vote

favorite












I have line to split window at start:



au VimEnter * vsplit


But sometimes it's annoying because I'm opening vim in small terminal, in this case I'd like to not spit my window. I've tried this construction but it's not executing at start



if winwidth('%') >= 100
au VimEnter * vsplit
endif


Is there a way to execute spit window depending on window size?










share|improve this question

























    up vote
    1
    down vote

    favorite












    I have line to split window at start:



    au VimEnter * vsplit


    But sometimes it's annoying because I'm opening vim in small terminal, in this case I'd like to not spit my window. I've tried this construction but it's not executing at start



    if winwidth('%') >= 100
    au VimEnter * vsplit
    endif


    Is there a way to execute spit window depending on window size?










    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I have line to split window at start:



      au VimEnter * vsplit


      But sometimes it's annoying because I'm opening vim in small terminal, in this case I'd like to not spit my window. I've tried this construction but it's not executing at start



      if winwidth('%') >= 100
      au VimEnter * vsplit
      endif


      Is there a way to execute spit window depending on window size?










      share|improve this question













      I have line to split window at start:



      au VimEnter * vsplit


      But sometimes it's annoying because I'm opening vim in small terminal, in this case I'd like to not spit my window. I've tried this construction but it's not executing at start



      if winwidth('%') >= 100
      au VimEnter * vsplit
      endif


      Is there a way to execute spit window depending on window size?







      neovim vim-windows






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 1 hour ago









      megas

      1495




      1495




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          Try moving the if into the autocommand:



          au VimEnter * if winwidth('%') >= 100 | vsplit | endif





          share|improve this answer



























            up vote
            3
            down vote













            You need to check the 'winwidth' result at the time the hook is run, not when it's defined. You can do this by putting it in a new function and calling that from the hook:



            function Widevsplit()
            if winwidth('%') >= 100
            vsplit
            endif
            endfunction

            au VimEnter * call Widevsplit()





            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: false,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













               

              draft saved


              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fvi.stackexchange.com%2fquestions%2f17418%2fconditional-window-split%23new-answer', 'question_page');

              );

              Post as a guest






























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              3
              down vote



              accepted










              Try moving the if into the autocommand:



              au VimEnter * if winwidth('%') >= 100 | vsplit | endif





              share|improve this answer
























                up vote
                3
                down vote



                accepted










                Try moving the if into the autocommand:



                au VimEnter * if winwidth('%') >= 100 | vsplit | endif





                share|improve this answer






















                  up vote
                  3
                  down vote



                  accepted







                  up vote
                  3
                  down vote



                  accepted






                  Try moving the if into the autocommand:



                  au VimEnter * if winwidth('%') >= 100 | vsplit | endif





                  share|improve this answer












                  Try moving the if into the autocommand:



                  au VimEnter * if winwidth('%') >= 100 | vsplit | endif






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 1 hour ago









                  Rich

                  13.5k11761




                  13.5k11761




















                      up vote
                      3
                      down vote













                      You need to check the 'winwidth' result at the time the hook is run, not when it's defined. You can do this by putting it in a new function and calling that from the hook:



                      function Widevsplit()
                      if winwidth('%') >= 100
                      vsplit
                      endif
                      endfunction

                      au VimEnter * call Widevsplit()





                      share|improve this answer
























                        up vote
                        3
                        down vote













                        You need to check the 'winwidth' result at the time the hook is run, not when it's defined. You can do this by putting it in a new function and calling that from the hook:



                        function Widevsplit()
                        if winwidth('%') >= 100
                        vsplit
                        endif
                        endfunction

                        au VimEnter * call Widevsplit()





                        share|improve this answer






















                          up vote
                          3
                          down vote










                          up vote
                          3
                          down vote









                          You need to check the 'winwidth' result at the time the hook is run, not when it's defined. You can do this by putting it in a new function and calling that from the hook:



                          function Widevsplit()
                          if winwidth('%') >= 100
                          vsplit
                          endif
                          endfunction

                          au VimEnter * call Widevsplit()





                          share|improve this answer












                          You need to check the 'winwidth' result at the time the hook is run, not when it's defined. You can do this by putting it in a new function and calling that from the hook:



                          function Widevsplit()
                          if winwidth('%') >= 100
                          vsplit
                          endif
                          endfunction

                          au VimEnter * call Widevsplit()






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 1 hour ago









                          JigglyNaga

                          28826




                          28826



























                               

                              draft saved


                              draft discarded















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fvi.stackexchange.com%2fquestions%2f17418%2fconditional-window-split%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