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

Re: How can I open help in the current window?

Expand Messages
  • Jorge
    ... then either move back gt (either gt or gT) or close the tab window (:tabclose or ctrl-w+c or :q ...) Regards, Helder -- -- You received this message from
    Message 1 of 13 , Apr 22, 2013
    • 0 Attachment
      On Monday, April 22, 2013 7:56:51 AM UTC-5, Phil Dobbin wrote:
      > On 22/04/2013 11:37, Thiago Padilha wrote:
      >
      >
      >
      > > I googled about this but only found how to open in a vertical split or
      >
      > > in a full window. I cannot find how can I navigate to help without
      >
      > > splitting or breaking my current layout.
      >
      > >
      >
      > > Normally I already have two windows splitting the screen vertically and
      >
      > > would like to open help in the current window then navigate back with
      >
      > > ctrl+o. Any easy way to accomplish that?
      >
      >
      >
      > I use:
      >
      >
      >
      > ':h foo.txt | only' to get the help files in the current window only but
      >
      > I'm unaware of a key command to return you back.
      >
      >
      >
      > I'm sure there is one & somebody will enlighten us with it shortly ;-)
      >
      >
      >
      > Cheers,
      >
      >
      >
      > Phil...

      I am sure there are better ways but you can use tabs:
      :tab help whatever

      then either move back gt (either gt or gT) or close the tab window (:tabclose or ctrl-w+c or :q ...)

      Regards,

      Helder

      --
      --
      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.
    • Tony Mechelynck
      ... (assuming of course that there isn t yet an open help window). From then on, the :help and :helpgrep commands (and the keystroke) will return to the
      Message 2 of 13 , Apr 22, 2013
      • 0 Attachment
        On 22/04/13 12:37, Thiago Padilha wrote:
        > I googled about this but only found how to open in a vertical split or
        > in a full window. I cannot find how can I navigate to help without
        > splitting or breaking my current layout.
        >
        > Normally I already have two windows splitting the screen vertically and
        > would like to open help in the current window then navigate back with
        > ctrl+o. Any easy way to accomplish that?
        >

        Actually, the solution is simple, maybe so simple no one thought of it:

        :view $VIMRUNTIME/doc/help.txt

        (assuming of course that there isn't yet an open help window). From then
        on, the :help and :helpgrep commands (and the <F1> keystroke) will
        return to the window where you viewed help.txt — but only as long as
        there is a helpfile in that window. You can go back from help.txt to
        whatever was there before with Ctrl-O but then that window loses its
        "help window" attribute and :help, :helpgrep or <F1> will open a new window.

        So you can always open help for subject foobar in the current window by
        doing

        :view $VIMRUNTIME/doc/help.txt | help foobar

        If you add the following mapping:

        :map <F1> :<C-U>view +1 $VIMRUNTIME/doc/help.txt<CR>

        (where <C-U> clears any possible count or visual mode which may have
        been present when you hit <F1>, and the +1 means "with the cursor on
        line 1"), then <F1> does its usual job but in the current window, and
        you can open the help for any subject in the current window by hitting
        <F1> immediately before typing your :help (or :helpgrep) command.

        Beware that with this mapping, if you hit <F1> while there _already_ is
        a help window in the current tab page, you will find yourself with a
        second help window open, and then I don't know which one of them will be
        affected by a following :help or :helpgrep command. Using

        :exe 'help' | q

        will close an existing help window (if any), of course, but it may also
        leave you in a different window than before, so adding that (minus colon
        and plus a bar at the end) between <C-U> and view seems not to be a
        solution if you want to avoid the risk of opening a second help window.


        Best regards,
        Tony.
        --
        "I'll rob that rich person and give it to some poor deserving slob.
        That will *prove* I'm Robin Hood."
        -- Daffy Duck, "Robin Hood Daffy", [1958, Chuck Jones]

        --
        --
        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.
      • Charles E Campbell
        C Campbell ... Manpageview does that (:OMan topic). You can get it from my website: http://www.drchip.org/astronaut/vim/index.html#MANPAGEVIEW You can also use
        Message 3 of 13 , Apr 23, 2013
        • 0 Attachment


          C Campbell

          On Apr 22, 2013, at 6:37 AM, Thiago Padilha <tpadilha84@...> wrote:

          I googled about this but only found how to open in a vertical split or in a full window. I cannot find how can I navigate to help without splitting or breaking my current layout.

          Normally I already have two windows splitting the screen vertically and would like to open help in the current window then navigate back with ctrl+o. Any easy way to accomplish that?

          --
          --
          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.
           

          Manpageview does that (:OMan topic).

           You can also use ZoomWin to use ctrl-o to expand a window to cover the whole vim display and use ctrl-o to go back.  (http://.../index.html#ZOOMWIN).

          Regards,
          Chip Campbell

          --
          --
          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.
           
           
        • Thiago de Arruda
          ... This isn t working for me, while the help doc is opened, the topic for foobar opens in another window. I have even tried :view $VIMRUNTIME/doc/help |
          Message 4 of 13 , Apr 23, 2013
          • 0 Attachment
            On 04/23, Tony Mechelynck wrote:
            >
            > So you can always open help for subject foobar in the current window
            > by doing
            >
            > :view $VIMRUNTIME/doc/help.txt | help foobar
            >

            This isn't working for me, while the help doc is opened, the topic for "foobar"
            opens in another window.

            I have even tried :view '$VIMRUNTIME/doc/help | setf help | help foobar' with no
            luck, the help topic always open in another window.

            I'm amazed that something that seems so simple is so difficult to accomplish in
            the most powerful editor :)

            --
            --
            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
            ... It seems to work for me, anyway. I d set up a command to do all this for you rather than typing it all every time, though. Or just use :tab help. -- -- You
            Message 5 of 13 , Apr 23, 2013
            • 0 Attachment
              On Tuesday, April 23, 2013 10:30:59 AM UTC-5, Thiago de Arruda wrote:
              > On 04/23, Tony Mechelynck wrote:
              >
              > >
              >
              > > So you can always open help for subject foobar in the current window
              >
              > > by doing
              >
              > >
              >
              > > :view $VIMRUNTIME/doc/help.txt | help foobar
              >
              > >
              >
              >
              >
              > This isn't working for me, while the help doc is opened, the topic for "foobar"
              >
              > opens in another window.
              >
              >
              >
              > I have even tried :view '$VIMRUNTIME/doc/help | setf help | help foobar' with no
              >
              > luck, the help topic always open in another window.
              >
              >
              >
              > I'm amazed that something that seems so simple is so difficult to accomplish in
              >
              > the most powerful editor :)

              I think the difference is that the :help command looks for a window with the 'buftype' option set to "help". :help 'buftype' says you're not supposed to set that manually, but I don't think there is anything preventing you from doing so. This should work slightly better:

              :view $VIMRUNTIME/doc/help.txt | set buftype=help | help foobar

              It seems to work for me, anyway. I'd set up a command to do all this for you rather than typing it all every time, though.

              Or just use :tab help.

              --
              --
              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.
            • Thiago de Arruda
              ... It worked for me Ben, thanks to you and all that responded to this thread! Using what I learned here I defined a new command that does what I need:
              Message 6 of 13 , Apr 23, 2013
              • 0 Attachment
                On 04/23, Ben Fritz wrote:
                > I think the difference is that the :help command looks for a window with the 'buftype' option set to "help". :help 'buftype' says you're not supposed to set that manually, but I don't think there is anything preventing you from doing so. This should work slightly better:
                >
                > :view $VIMRUNTIME/doc/help.txt | set buftype=help | help foobar
                >
                > It seems to work for me, anyway. I'd set up a command to do all this for you rather than typing it all every time, though.
                >
                > Or just use :tab help.
                >

                It worked for me Ben, thanks to you and all that responded to this thread!
                Using what I learned here I defined a new command that does what I need:

                function! OpenHelpInCurrentWindow(topic)
                keepjumps view $VIMRUNTIME/doc/help.txt
                setl filetype=help
                setl buftype=help
                setl nomodifiable
                exe 'help ' . a:topic
                endfunction

                command! -nargs=? -complete=help Help call OpenHelpInCurrentWindow(<q-args>)

                The only thing missing is to stop the first 'view' command from adding an entry
                to the jumplist. Apparently 'keepjumps' is having no effect, anyone has a better
                idea?

                Thanks again

                --
                --
                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.
              • Thiago de Arruda
                OK I finally managed to get fully working and will post here in case anyone is interested, just put the code in vimrc and you can quickly invoke help in the
                Message 7 of 13 , Apr 23, 2013
                • 0 Attachment
                  OK I finally managed to get fully working and will post here in case anyone is
                  interested, just put the code in vimrc and you can quickly invoke help in the
                  current window by pressing <leader>h:

                  function! OpenHelpInCurrentWindow(topic)
                  view $VIMRUNTIME/doc/help.txt
                  setl filetype=help
                  setl buftype=help
                  setl nomodifiable
                  exe 'keepjumps help ' . a:topic
                  endfunction

                  command! -nargs=? -complete=help Help call OpenHelpInCurrentWindow(<q-args>)

                  nnoremap <silent> <leader>h :view +1 $VIMRUNTIME/doc/help.txt

                  Thanks for everyone's tips

                  --
                  --
                  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.
                • Edward Beckett
                  you could simply open a new instance or tab for help ... -- -- You received this message from the vim_use maillist. Do not top-post! Type your reply below
                  Message 8 of 13 , Apr 23, 2013
                  • 0 Attachment

                    you could simply open a new instance or tab for help

                    On Apr 22, 2013 6:37 AM, "Thiago Padilha" <tpadilha84@...> wrote:
                    I googled about this but only found how to open in a vertical split or in a full window. I cannot find how can I navigate to help without splitting or breaking my current layout.

                    Normally I already have two windows splitting the screen vertically and would like to open help in the current window then navigate back with ctrl+o. Any easy way to accomplish that?

                    --
                    --
                    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.
                     
                     

                    --
                    --
                    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.
                     
                     
                  • Thiago de Arruda
                    ... I d rather open the help in full height in the current window then navigate back with CTRL+O, which is already how I m used to navigate between files.
                    Message 9 of 13 , Apr 24, 2013
                    • 0 Attachment
                      On 04/23, Edward Beckett wrote:
                      > you could simply open a new instance or tab for help

                      I'd rather open the help in full height in the current window then navigate back
                      with CTRL+O, which is already how I'm used to navigate between files. Besides,
                      since I already use tmux with multiple vim instances, tabs get redundant for me.
                    • Edward Beckett
                      hmm... well if you get an answer do tell... your work flow does sound rather convenient... ... -- -- You received this message from the vim_use maillist. Do
                      Message 10 of 13 , Apr 24, 2013
                      • 0 Attachment

                        hmm... well if you get an answer do tell... your work flow does sound rather convenient...

                        On Apr 24, 2013 8:11 AM, "Thiago de Arruda" <tpadilha84@...> wrote:
                        On 04/23, Edward Beckett wrote:
                        > you could simply open a new instance or tab for help

                        I'd rather open the help in full height in the current window then navigate back
                        with CTRL+O, which is already how I'm used to navigate between files. Besides,
                        since I already use tmux with multiple vim instances, tabs get redundant for me.

                        --
                        --
                        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.
                         
                         
                      • Thiago de Arruda
                        ... As I decribed in my previous email, I managed to get a working solution by placing this code in my vimrc: function! OpenHelpInCurrentWindow(topic) view
                        Message 11 of 13 , Apr 24, 2013
                        • 0 Attachment
                          On 04/24, Edward Beckett wrote:
                          > hmm... well if you get an answer do tell... your work flow does sound
                          > rather convenient...

                          As I decribed in my previous email, I managed to get a working solution by
                          placing this code in my vimrc:

                          function! OpenHelpInCurrentWindow(topic)
                          view $VIMRUNTIME/doc/help.txt
                          setl filetype=help
                          setl buftype=help
                          setl nomodifiable
                          exe 'keepjumps help ' . a:topic
                          endfunction

                          command! -nargs=? -complete=help Help call OpenHelpInCurrentWindow(<q-args>)

                          nnoremap <silent> <leader>h :Help

                          Then with <leader>h or :Help you can open a help topic in the current window
                        Your message has been successfully submitted and would be delivered to recipients shortly.