Loading ...
Sorry, an error occurred while loading the content.

vim: help for scripting

Expand Messages
  • ping
    whenever I come to a scenario that I have to (or better) script in vim , it becomes a big headache and time consuming work -- turning my goal of efficiency
    Message 1 of 15 , Feb 6 1:08 PM
    • 0 Attachment
      whenever I come to a scenario that I have to (or better) script in vim ,
      it becomes a big headache and time consuming work -- turning my goal of
      efficiency boosting to the reverse effect --- spending a lotof time
      without success. I feel guilty to seek help for "simple-looking" task,
      but seems I have to...

      ok, anyway...

      say I want to achive one thing :
      in some setups , I need to open 2 new window for some quick work, and I
      can hit <cr> to jump between that 2 new windows (you will know better
      what I'm
      talking about if you ever used Voom plugin or other similiar tools)

      now , after some while I want to close those 2 newly opened windows --
      of course I can just close them manually, but I think this is really
      something can be done via a small map or func, making it much easier if
      I can then map it to a short key. so here is what I thought "should
      have" worked but not...

      function! QuitNR()
      "get number of one win
      let wn_curr=winnr()
      "jump to the other win
      normal! <CR>
      "get number of that win
      let wn_pair=winnr()
      "jump to the window
      exec wn_curr . "wincmd w"
      "close it
      close
      "jump to the other one
      exec wn_pair . "wincmd w"
      "and close that one too
      close
      endfu

      nn vV :call QuitNR()<CR>

      it looks sth got break in it, at least followig doesn't work when I
      tested it manually:

      normal! <CR>

      I thought this is equivalent to hitting a return, which jumps to the
      other window , which is what will happen if I hit return myself in
      Voom...but
      that "jump" doesn't happen here in the script.

      any thought?


      --
      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Marc Weber
      jumping bufs, opening bufs is something you do most. Thus you should map that. Eg see line 7 to 10:
      Message 2 of 15 , Feb 6 1:21 PM
      • 0 Attachment
        jumping bufs, opening bufs is something you do most.
        Thus you should map that.
        Eg see line 7 to 10:
        https://github.com/MarcWeber/vim-addon-other/blob/master/plugin/vim-addon-other.vim

        Its hard to help without actually reading all the code

        Instead of using normal <cr> Sometimes using feedkeys function is faster
        than coding much viml.

        You can debug the command by:

        debug normal <cr>

        and see what it triggers by stepping with s.
        You can also try

        map <cr>

        to see whether the mapping already exist.

        You can also lookup what <cr> is mapped to, and use that code instead.

        Maybe these ideas already help you.

        Marc Weber

        --
        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Marcin Szamotulski
        ... Hi, You should not use :normal! but rather :normal . The different is that :normal! does not take any user specific maps, and since in normal
        Message 3 of 15 , Feb 6 1:50 PM
        • 0 Attachment
          On 16:08 Wed 06 Feb , ping wrote:
          >
          > whenever I come to a scenario that I have to (or better) script in vim ,
          > it becomes a big headache and time consuming work -- turning my goal of
          > efficiency boosting to the reverse effect --- spending a lotof time
          > without success. I feel guilty to seek help for "simple-looking" task,
          > but seems I have to...
          >
          > ok, anyway...
          >
          > say I want to achive one thing :
          > in some setups , I need to open 2 new window for some quick work, and I
          > can hit <cr> to jump between that 2 new windows (you will know better
          > what I'm
          > talking about if you ever used Voom plugin or other similiar tools)
          >
          > now , after some while I want to close those 2 newly opened windows --
          > of course I can just close them manually, but I think this is really
          > something can be done via a small map or func, making it much easier if
          > I can then map it to a short key. so here is what I thought "should
          > have" worked but not...
          >
          > function! QuitNR()
          > "get number of one win
          > let wn_curr=winnr()
          > "jump to the other win
          > normal! <CR>
          > "get number of that win
          > let wn_pair=winnr()
          > "jump to the window
          > exec wn_curr . "wincmd w"
          > "close it
          > close
          > "jump to the other one
          > exec wn_pair . "wincmd w"
          > "and close that one too
          > close
          > endfu
          >
          > nn vV :call QuitNR()<CR>
          >
          > it looks sth got break in it, at least followig doesn't work when I
          > tested it manually:
          >
          > normal! <CR>
          >
          > I thought this is equivalent to hitting a return, which jumps to the
          > other window , which is what will happen if I hit return myself in
          > Voom...but
          > that "jump" doesn't happen here in the script.
          >
          > any thought?
          >
          >
          > --
          > --
          > You received this message from the "vim_use" maillist.
          > Do not top-post! Type your reply below the text you are replying to.
          > For more information, visit http://www.vim.org/maillist.php
          >
          > ---
          > You received this message because you are subscribed to the Google Groups "vim_use" group.
          > To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
          > For more options, visit https://groups.google.com/groups/opt_out.
          >

          Hi,

          You should not use :normal! <CR> but rather :normal <CR>. The different
          is that :normal! does not take any user specific maps, and since in
          normal mode <CR> is just a jump to next line, it will just go to the
          beginning of next line. This also applies to your manual test. It just
          should be
          :normal <CR>
          without the bang. See ':help :normal'.

          I hope it helps,
          Marcin

          --
          --
          You received this message from the "vim_use" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php

          ---
          You received this message because you are subscribed to the Google Groups "vim_use" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Ben Fritz
          ... You used a ! at the end of your command. See :help :normal. Using a ! says don t use any mappings . This is a rare case where you actually need to
          Message 4 of 15 , Feb 6 1:54 PM
          • 0 Attachment
            On Wednesday, February 6, 2013 3:08:14 PM UTC-6, ping wrote:
            > it looks sth got break in it, at least followig doesn't work when I
            >
            > tested it manually:
            >
            >
            >
            > normal! <CR>
            >
            >
            >
            > I thought this is equivalent to hitting a return, which jumps to the
            >
            > other window , which is what will happen if I hit return myself in
            >
            > Voom

            You used a '!' at the end of your command. See :help :normal. Using a '!' says "don't use any mappings". This is a rare case where you actually need to leave it off.

            You might have another problem, because you get two window numbers, save them off, then try to jump to each in turn to close them.

            As soon as you close the first window, all the windows potentially get renumbered. You can pull it off by always jumping to and closing the largest numbered window number first.

            --
            --
            You received this message from the "vim_use" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php

            ---
            You received this message because you are subscribed to the Google Groups "vim_use" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
            For more options, visit https://groups.google.com/groups/opt_out.
          • ping
            ... thanks Ben and Marcin for pointing this out. I understood now that this is one of the scenario that I need to retain the origin mappings without ! in
            Message 5 of 15 , Feb 6 2:13 PM
            • 0 Attachment
              On 02/06/2013 04:54 PM, Ben Fritz wrote:
              > On Wednesday, February 6, 2013 3:08:14 PM UTC-6, ping wrote:
              >> it looks sth got break in it, at least followig doesn't work when I
              >>
              >> tested it manually:
              >>
              >>
              >>
              >> normal! <CR>
              >>
              >>
              >>
              >> I thought this is equivalent to hitting a return, which jumps to the
              >>
              >> other window , which is what will happen if I hit return myself in
              >>
              >> Voom
              > You used a '!' at the end of your command. See :help :normal. Using a '!' says "don't use any mappings". This is a rare case where you actually need to leave it off.
              thanks Ben and Marcin for pointing this out.
              I understood now that this is one of the scenario that I need to retain
              the origin mappings without "!" in normal.
              but the problem here is, that <cr> to jump between 2 window apparently
              wasn't implemented via the regular vim map, but it comes with the Voom
              plugin , written in python. I guess that's why even without "!" it won't
              jump with "normal <CR>". it seems only work with a manual return hit...

              this makes me think that actually the vim 'normal' command is not
              actually reliably reproducing what we did manually in normal mode.
              so is that any good way to completely simulate a real "hit return"
              exactly as what will be triggered when doing it manually?

              >
              > You might have another problem, because you get two window numbers, save them off, then try to jump to each in turn to close them.
              yes this is what my idea was.
              >
              > As soon as you close the first window, all the windows potentially get renumbered.
              I really didn't know this...so its a dynamic numbering then..good to learn.
              > You can pull it off by always jumping to and closing the largest numbered window number first.
              good ideal. that part can be fixed based on this.

              function! QuitNR()
              let wn_curr=winnr()
              normal <CR>
              let wn_pair=winnr()
              let wn_larger=wn_curr > wn_pair ? wn_curr : wn_pair
              let wn_smaller=wn_curr < wn_pair ? wn_curr : wn_pair
              exec wn_larger . "wincmd w"
              close
              exec wn_smaller . "wincmd w"
              close
              endfu


              --
              --
              You received this message from the "vim_use" maillist.
              Do not top-post! Type your reply below the text you are replying to.
              For more information, visit http://www.vim.org/maillist.php

              ---
              You received this message because you are subscribed to the Google Groups "vim_use" group.
              To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
              For more options, visit https://groups.google.com/groups/opt_out.
            • Marc Weber
              ... Do what I said: 1) use map to find out whether the mapping already exist when you run the code. 2) lookup how the the Voom plugin does map to a
              Message 6 of 15 , Feb 6 2:20 PM
              • 0 Attachment
                > wasn't implemented via the regular vim map, but it comes with the Voom
                > plugin , written in python.
                Do what I said:
                1) use map <cr> to find out whether the mapping already
                exist when you run the code.
                2) lookup how the the Voom plugin does map <CR> to a key.
                There is no python magic - all mappings are done in Vim - so you're
                likely to be wrong about assuming its related to python.

                grep the plugin code for CR and cr and you'll be lucky. Then try using
                the right hand side instead of sendig <cr> - you may get more helpful
                error messages then.

                Marc Weber

                --
                --
                You received this message from the "vim_use" maillist.
                Do not top-post! Type your reply below the text you are replying to.
                For more information, visit http://www.vim.org/maillist.php

                ---
                You received this message because you are subscribed to the Google Groups "vim_use" group.
                To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                For more options, visit https://groups.google.com/groups/opt_out.
              • Marcin Szamotulski
                ... I am not aware of the Voom plugin, but it may define buffer local maps. (see :help map- ). Regards, Marcin -- -- You received this message from
                Message 7 of 15 , Feb 6 2:39 PM
                • 0 Attachment
                  On 23:20 Wed 06 Feb , Marc Weber wrote:
                  > > wasn't implemented via the regular vim map, but it comes with the Voom
                  > > plugin , written in python.
                  > Do what I said:
                  > 1) use map <cr> to find out whether the mapping already
                  > exist when you run the code.
                  > 2) lookup how the the Voom plugin does map <CR> to a key.
                  > There is no python magic - all mappings are done in Vim - so you're
                  > likely to be wrong about assuming its related to python.
                  >
                  > grep the plugin code for CR and cr and you'll be lucky. Then try using
                  > the right hand side instead of sendig <cr> - you may get more helpful
                  > error messages then.
                  >
                  > Marc Weber
                  >
                  > --
                  > --
                  > You received this message from the "vim_use" maillist.
                  > Do not top-post! Type your reply below the text you are replying to.
                  > For more information, visit http://www.vim.org/maillist.php
                  >
                  > ---
                  > You received this message because you are subscribed to the Google Groups "vim_use" group.
                  > To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                  > For more options, visit https://groups.google.com/groups/opt_out.
                  >

                  I am not aware of the Voom plugin, but it may define buffer local maps.
                  (see ':help map-<buffer>').

                  Regards,
                  Marcin

                  --
                  --
                  You received this message from the "vim_use" maillist.
                  Do not top-post! Type your reply below the text you are replying to.
                  For more information, visit http://www.vim.org/maillist.php

                  ---
                  You received this message because you are subscribed to the Google Groups "vim_use" group.
                  To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                  For more options, visit https://groups.google.com/groups/opt_out.
                • ping
                  ... I got no mapping found ... I agree now that I m wrong on that. so I got these from the plugin code: Which key to map to
                  Message 8 of 15 , Feb 6 7:45 PM
                  • 0 Attachment
                    On 2/6/2013 5:39 PM, Marcin Szamotulski wrote:
                    > 1) use map <cr> to find out whether the mapping already
                    > >exist when you run the code.
                    I got "no mapping found"
                    > >2) lookup how the the Voom plugin does map <CR> to a key.
                    > >There is no python magic - all mappings are done in Vim - so you're
                    > >likely to be wrong about assuming its related to python.
                    I agree now that I'm wrong on that.
                    so I got these from the plugin code:

                    " Which key to map to Select-Node-and-Shuttle-between-Body/Tree
                    if !exists('g:voom_return_key')
                    let g:voom_return_key = '<Return>'
                    endif

                    ......

                    exe "nnoremap <buffer><silent> ".g:voom_return_key." :<C-u>call
                    Voom_TreeSelect(0)<CR>"
                    exe "vnoremap <buffer><silent> ".g:voom_return_key." <Esc>:<C-u>call
                    Voom_TreeSelect(0)<CR>"
                    "exe "vnoremap <buffer><silent> ".g:voom_return_key." <Nop>"
                    exe "nnoremap <buffer><silent> ".g:voom_tab_key." :<C-u>call
                    Voom_ToTreeOrBodyWin()<CR>"
                    exe "vnoremap <buffer><silent> ".g:voom_tab_key." <Esc>:<C-u>call
                    Voom_ToTreeOrBodyWin()<CR>"
                    "exe "vnoremap <buffer><silent> ".g:voom_tab_key." <Nop>"

                    > >
                    > >grep the plugin code for CR and cr and you'll be lucky. Then try using
                    > >the right hand side instead of sendig <cr> - you may get more helpful
                    > >error messages then.
                    this is a bit complex kind of map... so based on that , how can I make a
                    jump within my script?
                    I tried:
                    exec "<C-u>call Voom_TreeSelect(0)<CR>"

                    it seems not work:

                    Error detected while processing function QuitNR:
                    line 11:
                    E488: Trailing characters: <C-u>call Voom_TreeSelect(0)<CR>
                    Press ENTER or type command to continue


                    thanks.

                    --
                    --
                    You received this message from the "vim_use" maillist.
                    Do not top-post! Type your reply below the text you are replying to.
                    For more information, visit http://www.vim.org/maillist.php

                    ---
                    You received this message because you are subscribed to the Google Groups "vim_use" group.
                    To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                    For more options, visit https://groups.google.com/groups/opt_out.
                  • Marcin Szamotulski
                    ... To call a function it is enough to write: call VoomTreeSelect(0) in you vimscript. However if you want to use :execute command (but you don t need to):
                    Message 9 of 15 , Feb 7 12:42 AM
                    • 0 Attachment
                      On 22:45 Wed 06 Feb , ping wrote:
                      > On 2/6/2013 5:39 PM, Marcin Szamotulski wrote:
                      > > 1) use map <cr> to find out whether the mapping already
                      > > >exist when you run the code.
                      > I got "no mapping found"
                      > > >2) lookup how the the Voom plugin does map <CR> to a key.
                      > > >There is no python magic - all mappings are done in Vim - so you're
                      > > >likely to be wrong about assuming its related to python.
                      > I agree now that I'm wrong on that.
                      > so I got these from the plugin code:
                      >
                      > " Which key to map to Select-Node-and-Shuttle-between-Body/Tree
                      > if !exists('g:voom_return_key')
                      > let g:voom_return_key = '<Return>'
                      > endif
                      >
                      > ......
                      >
                      > exe "nnoremap <buffer><silent> ".g:voom_return_key." :<C-u>call
                      > Voom_TreeSelect(0)<CR>"
                      > exe "vnoremap <buffer><silent> ".g:voom_return_key." <Esc>:<C-u>call
                      > Voom_TreeSelect(0)<CR>"
                      > "exe "vnoremap <buffer><silent> ".g:voom_return_key." <Nop>"
                      > exe "nnoremap <buffer><silent> ".g:voom_tab_key." :<C-u>call
                      > Voom_ToTreeOrBodyWin()<CR>"
                      > exe "vnoremap <buffer><silent> ".g:voom_tab_key." <Esc>:<C-u>call
                      > Voom_ToTreeOrBodyWin()<CR>"
                      > "exe "vnoremap <buffer><silent> ".g:voom_tab_key." <Nop>"
                      >
                      > > >
                      > > >grep the plugin code for CR and cr and you'll be lucky. Then try using
                      > > >the right hand side instead of sendig <cr> - you may get more helpful
                      > > >error messages then.
                      > this is a bit complex kind of map... so based on that , how can I make a
                      > jump within my script?
                      > I tried:
                      > exec "<C-u>call Voom_TreeSelect(0)<CR>"
                      >
                      > it seems not work:
                      >
                      > Error detected while processing function QuitNR:
                      > line 11:
                      > E488: Trailing characters: <C-u>call Voom_TreeSelect(0)<CR>
                      > Press ENTER or type command to continue
                      >
                      >
                      > thanks.
                      To call a function it is enough to write:

                      call VoomTreeSelect(0)

                      in you vimscript. However if you want to use :execute command (but you
                      don't need to):

                      exe 'call VoomTreeSelect(0)'

                      Both <c-u> and <cr> are not needed. An example of a usage of <c-u> and
                      <cr> is when you define a map via :exe :

                      exe 'map E :<C-U>call VoomTreeSelect(0)<CR>'

                      and I presume you took your syntax from here. The difference is that
                      the right hand side of a map is not the same as what exe statement is
                      using. :exe executes expressions as an Ex command while the right hand
                      side of a map is a bunch of normal commands, where ':' is used to enter
                      the command line. If you enter it in the visual mode, then it will
                      start with range '<,>' and <c-u> is used to delete it.

                      Best,
                      Marcin

                      --
                      --
                      You received this message from the "vim_use" maillist.
                      Do not top-post! Type your reply below the text you are replying to.
                      For more information, visit http://www.vim.org/maillist.php

                      ---
                      You received this message because you are subscribed to the Google Groups "vim_use" group.
                      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                      For more options, visit https://groups.google.com/groups/opt_out.
                    • Marc Weber
                      ... Let s you overide the key. ... THis means fill in the setting defined above. Thus its basically: nnoremap : call
                      Message 10 of 15 , Feb 7 4:08 AM
                      • 0 Attachment
                        > if !exists('g:voom_return_key')
                        > let g:voom_return_key = '<Return>'
                        > endif

                        Let's you overide the <CR> key.

                        > exe "nnoremap <buffer><silent> ".g:voom_return_key." :<C-u>call Voom_TreeSelect(0)<CR>"
                        THis means fill in the setting defined above. Thus its basically:

                        nnoremap <buffer><silent> <CR> :<c-u>call Voom_TreeSelect(0)

                        You only want what vim call the RHS (righthandside): call Voom_TreeSelect(...)
                        Use that instead of normal "<cr>"

                        At least you should have enough info now to find a way to succeed.

                        Marc Weber

                        --
                        --
                        You received this message from the "vim_use" maillist.
                        Do not top-post! Type your reply below the text you are replying to.
                        For more information, visit http://www.vim.org/maillist.php

                        ---
                        You received this message because you are subscribed to the Google Groups "vim_use" group.
                        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                        For more options, visit https://groups.google.com/groups/opt_out.
                      • ping
                        ... thanks for all of those good info, it s really nice to learn. I ve saved these notes and later references also. now with this: call Voom_ToTreeOrBodyWin()
                        Message 11 of 15 , Feb 7 6:21 AM
                        • 0 Attachment
                          On 2/7/2013 7:08 AM, Marc Weber wrote:
                          >> if !exists('g:voom_return_key')
                          >> let g:voom_return_key = '<Return>'
                          >> endif
                          > Let's you overide the <CR> key.
                          >
                          >> exe "nnoremap <buffer><silent> ".g:voom_return_key." :<C-u>call Voom_TreeSelect(0)<CR>"
                          > THis means fill in the setting defined above. Thus its basically:
                          >
                          > nnoremap <buffer><silent> <CR> :<c-u>call Voom_TreeSelect(0)
                          >
                          > You only want what vim call the RHS (righthandside): call Voom_TreeSelect(...)
                          > Use that instead of normal "<cr>"
                          >
                          > At least you should have enough info now to find a way to succeed.
                          >
                          > Marc Weber
                          >
                          thanks for all of those good info, it's really nice to learn.
                          I've saved these notes and later references also.

                          now with this:
                          call Voom_ToTreeOrBodyWin()

                          in my script:
                          function! QuitNR()
                          "get number of one win in voom
                          let wn_curr=winnr()

                          "normal <CR>
                          call Voom_ToTreeOrBodyWin()

                          let wn_pair=winnr()
                          let wn_larger=wn_curr > wn_pair ? wn_curr : wn_pair
                          let wn_smaller=wn_curr < wn_pair ? wn_curr : wn_pair

                          "jump larger win first
                          exec wn_larger . "wincmd w"
                          "close the win
                          close
                          "then jump to the smaller win and close it out
                          exec wn_smaller . "wincmd w"
                          close
                          endfu
                          nn vV :call QuitNR()<CR>

                          I succeed!

                          thanks for all the helps and good notes! you guys make this alias
                          extremely helpful...



                          regards
                          ping


                          --
                          --
                          You received this message from the "vim_use" maillist.
                          Do not top-post! Type your reply below the text you are replying to.
                          For more information, visit http://www.vim.org/maillist.php

                          ---
                          You received this message because you are subscribed to the Google Groups "vim_use" group.
                          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                          For more options, visit https://groups.google.com/groups/opt_out.
                        • Benji Fisher
                          Maybe this is too little, too late, but your syntax was wrong. If you want to emulate hitting Enter, then the right way is ... (and scroll down to the
                          Message 12 of 15 , Feb 7 10:47 AM
                          • 0 Attachment
                            Maybe this is too little, too late, but your syntax was wrong.  If you want to emulate hitting Enter, then the right way is

                            :execute "normal \<CR>"

                            :help :normal

                            (and scroll down to the example).

                            -- 
                            HTH
                            Benji Fisher


                            On Thu, Feb 7, 2013 at 9:21 AM, ping <songpingemail@...> wrote:
                            On 2/7/2013 7:08 AM, Marc Weber wrote:
                               if !exists('g:voom_return_key')
                                   let g:voom_return_key = '<Return>'
                               endif
                            Let's you overide the <CR> key.
                             
                            exe "nnoremap <buffer><silent> ".g:voom_return_key." :<C-u>call Voom_TreeSelect(0)<CR>"
                            THis means fill in the setting defined above. Thus its basically:

                            nnoremap <buffer><silent> <CR> :<c-u>call Voom_TreeSelect(0)

                            You only want what vim call the RHS (righthandside): call Voom_TreeSelect(...)
                            Use that instead of normal "<cr>"

                            At least you should have enough info now to find a way to succeed.

                            Marc Weber

                            thanks for all of those good info, it's really nice to learn.
                            I've saved these notes and later references also.

                            now with this:
                            call Voom_ToTreeOrBodyWin()

                            in my script:
                            function! QuitNR()
                                "get number of one win in voom
                                let wn_curr=winnr()

                                "normal <CR>
                                call Voom_ToTreeOrBodyWin()


                                let wn_pair=winnr()
                                let wn_larger=wn_curr > wn_pair ? wn_curr : wn_pair
                                let wn_smaller=wn_curr < wn_pair ? wn_curr : wn_pair

                                "jump larger win first

                                exec wn_larger . "wincmd w"
                                "close the win
                                close
                                "then jump to the smaller win and close it out

                                exec wn_smaller . "wincmd w"
                                close
                            endfu
                            nn vV :call QuitNR()<CR>

                            I succeed!

                            thanks for all the helps and good notes! you guys make this alias extremely helpful...



                            regards
                            ping



                            --
                            --
                            You received this message from the "vim_use" maillist.
                            Do not top-post! Type your reply below the text you are replying to.
                            For more information, visit http://www.vim.org/maillist.php

                            --- You received this message because you are subscribed to the Google Groups "vim_use" group.
                            To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
                            For more options, visit https://groups.google.com/groups/opt_out.



                            --
                            --
                            You received this message from the "vim_use" maillist.
                            Do not top-post! Type your reply below the text you are replying to.
                            For more information, visit http://www.vim.org/maillist.php
                             
                            ---
                            You received this message because you are subscribed to the Google Groups "vim_use" group.
                            To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                            For more options, visit https://groups.google.com/groups/opt_out.
                             
                             
                          • ping
                            ... ohhh...this looks a more generic solution... it works perfectly in all cases! thanks! -- -- You received this message from the vim_use maillist. Do not
                            Message 13 of 15 , Feb 7 10:52 AM
                            • 0 Attachment
                              On 2/7/2013 1:47 PM, Benji Fisher wrote:
                              > Maybe this is too little, too late, but your syntax was wrong. If you
                              > want to emulate hitting Enter, then the right way is
                              >
                              > :execute "normal \<CR>"
                              >
                              > :help :normal
                              ohhh...this looks a more generic solution...
                              it works perfectly in all cases! thanks!

                              --
                              --
                              You received this message from the "vim_use" maillist.
                              Do not top-post! Type your reply below the text you are replying to.
                              For more information, visit http://www.vim.org/maillist.php

                              ---
                              You received this message because you are subscribed to the Google Groups "vim_use" group.
                              To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                              For more options, visit https://groups.google.com/groups/opt_out.
                            • Vlad Irnov
                              ... Hi Ping, Please use the github page or email me directly for any VOoM-specific requests. Scripting of VOoM should not be attempted without my supervision!
                              Message 14 of 15 , Feb 7 5:10 PM
                              • 0 Attachment
                                On 2/7/13, ping <songpingemail@...> wrote:
                                > On 2/7/2013 7:08 AM, Marc Weber wrote:
                                >>> if !exists('g:voom_return_key')
                                >>> let g:voom_return_key = '<Return>'
                                >>> endif
                                >> Let's you overide the <CR> key.
                                >>
                                >>> exe "nnoremap <buffer><silent> ".g:voom_return_key." :<C-u>call
                                >>> Voom_TreeSelect(0)<CR>"
                                >> THis means fill in the setting defined above. Thus its basically:
                                >>
                                >> nnoremap <buffer><silent> <CR> :<c-u>call Voom_TreeSelect(0)
                                >>
                                >> You only want what vim call the RHS (righthandside): call
                                >> Voom_TreeSelect(...)
                                >> Use that instead of normal "<cr>"
                                >>
                                >> At least you should have enough info now to find a way to succeed.
                                >>
                                >> Marc Weber
                                >>
                                > thanks for all of those good info, it's really nice to learn.
                                > I've saved these notes and later references also.
                                >
                                > now with this:
                                > call Voom_ToTreeOrBodyWin()
                                >
                                > in my script:
                                > function! QuitNR()
                                > "get number of one win in voom
                                > let wn_curr=winnr()
                                >
                                > "normal <CR>
                                > call Voom_ToTreeOrBodyWin()
                                >
                                > let wn_pair=winnr()
                                > let wn_larger=wn_curr > wn_pair ? wn_curr : wn_pair
                                > let wn_smaller=wn_curr < wn_pair ? wn_curr : wn_pair
                                >
                                > "jump larger win first
                                > exec wn_larger . "wincmd w"
                                > "close the win
                                > close
                                > "then jump to the smaller win and close it out
                                > exec wn_smaller . "wincmd w"
                                > close
                                > endfu
                                > nn vV :call QuitNR()<CR>
                                >
                                > I succeed!
                                >
                                > thanks for all the helps and good notes! you guys make this alias
                                > extremely helpful...

                                Hi Ping,

                                Please use the github page or email me directly for any VOoM-specific
                                requests.

                                Scripting of VOoM should not be attempted without my supervision! All
                                plugin functions are global because this is how I like it, but you
                                cannot just call any function from any buffer.

                                Closing windows one by one is a bit complicated. There is utility
                                function Voom_DeleteOutline([command]) which you can use to
                                simultaneously close the current window and to delete the associated
                                Tree buffer, if any. See VOoM help for details, section
                                |voom_quit|. In your case, define a global mapping like this:
                                :nnoremap <silent> vV :call Voom_DeleteOutline('close')<CR>
                                Then you can get rid of both the source window and the associated Tree
                                buffer with at most two commands: move to the source window (<Cr> or
                                <Tab>) and press "vV". Instead of 'close' you can specify 'bd' or 'bw'
                                or 'q'.

                                Regards, Vlad

                                --
                                --
                                You received this message from the "vim_use" maillist.
                                Do not top-post! Type your reply below the text you are replying to.
                                For more information, visit http://www.vim.org/maillist.php

                                ---
                                You received this message because you are subscribed to the Google Groups "vim_use" group.
                                To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                                For more options, visit https://groups.google.com/groups/opt_out.
                              • ping
                                ... thanks Vlad, that s definitely more neat way. but what if I want to archive the same effect regardless of which window my cursor is currently is, body or
                                Message 15 of 15 , Feb 7 8:56 PM
                                • 0 Attachment
                                  On 2/7/2013 8:10 PM, Vlad Irnov wrote:
                                  |voom_quit|. In your case, define a global mapping like this:
                                      :nnoremap <silent> vV :call Voom_DeleteOutline('close')<CR>
                                  Then you can get rid of both the source window and the associated Tree
                                  buffer with at most two commands: move to the source window (<Cr> or
                                  <Tab>) and press "vV". Instead of 'close' you can specify 'bd' or 'bw'
                                  or 'q'.
                                  thanks Vlad, that's definitely more neat way.
                                  but what if I want to archive the same effect regardless of which window my cursor is currently is, body or tree?
                                  I did a quick test, and it looks as you pointed out I need to move my cursor in the body and invoke the Voom_DeleteOutline() function.
                                  the reason I wanted the "jump"-and-"record the winnr" method is to make sure I got the same result regardless of my positon (body or tree).

                                  b.t.w, it may looks a stupid desire that why I need this, the real driver is that I'm using nrrw over Voom. so very frequently I need to invoke a new
                                  nrrwrgn over the VOom-ed buffer, highlight/outline it with voom again (now I have 2 pairs of Voom-ed buffer --- 4 windows),
                                  and I need to close the 2 new windows after that quick work done.

                                  regards
                                  ping
                                   


                                  --
                                  --
                                  You received this message from the "vim_use" maillist.
                                  Do not top-post! Type your reply below the text you are replying to.
                                  For more information, visit http://www.vim.org/maillist.php
                                   
                                  ---
                                  You received this message because you are subscribed to the Google Groups "vim_use" group.
                                  To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                                  For more options, visit https://groups.google.com/groups/opt_out.
                                   
                                   
                                Your message has been successfully submitted and would be delivered to recipients shortly.