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

How to disable mouse scroll wheel when in insert mode?

Expand Messages
  • Glenn Todd Miller
    Long time vim user looking for some advice on this, tried searching the web to no avail. I am using CentOS 6 and vim 7.2.411. My issue: In vim, I am in INSERT
    Message 1 of 12 , Jan 24, 2014
    • 0 Attachment

      Long time vim user looking for some advice on this, tried searching the

      web to no avail.  I am using CentOS 6 and vim 7.2.411.

       

      My issue: In vim, I am in INSERT mode, my cursor is where I want it to be

      for a PASTE operation, but when I press the middle mouse button (which in

      my case is a scroll wheel) to do the paste the wheel moves inadvertently

      and I end up pasting somewhere else, not in the place where my cursor

      was when I entered INSERT mode.

       

      Is there a way to configure vim so that the mouse scroll wheel/middle

      mouse button is disabled when in INSERT mode?

       

      Outside of insert mode the mouse scroll is a great feature, so I only

      want to disable it when in insert mode.

      Thanks for any 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.
    • Marcin Szamotulski
      ... I don t think that you can disable the mouse wheel. But you can use ^r in insert mode to paste from various registers, e.g. from clipboard. Read more in
      Message 2 of 12 , Jan 24, 2014
      • 0 Attachment
        On 18:46 Fri 24 Jan , Glenn Todd Miller wrote:
        > Long time vim user looking for some advice on this, tried searching the
        > web to no avail. I am using CentOS 6 and vim 7.2.411.
        >
        > My issue: In vim, I am in INSERT mode, my cursor is where I want it to be
        > for a PASTE operation, but when I press the middle mouse button (which in
        > my case is a scroll wheel) to do the paste the wheel moves inadvertently
        > and I end up pasting somewhere else, not in the place where my cursor
        > was when I entered INSERT mode.
        >
        > Is there a way to configure vim so that the mouse scroll wheel/middle
        > mouse button is disabled when in INSERT mode?
        >
        > Outside of insert mode the mouse scroll is a great feature, so I only
        > want to disable it when in insert mode.
        > Thanks for any 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.


        I don't think that you can disable the mouse wheel. But you can use
        ^r in insert mode to paste from various registers, e.g. from clipboard.
        Read more in :help i^r

        Best regards,
        Marcin Szamotulski

        --
        --
        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.
      • Israel Chauca
        ... The following mappings seem to do the trick: inoremap inoremap ... and looking on the listed items. is
        Message 3 of 12 , Jan 25, 2014
        • 0 Attachment
          On 1/24/14, 1:46 PM, Glenn Todd Miller wrote:
          > Long time vim user looking for some advice on this, tried searching the
          > web to no avail. I am using CentOS 6 and vim 7.2.411.
          >
          > My issue: In vim, I am in INSERT mode, my cursor is where I want it to be
          > for a PASTE operation, but when I press the middle mouse button (which in
          > my case is a scroll wheel) to do the paste the wheel moves inadvertently
          > and I end up pasting somewhere else, not in the place where my cursor
          > was when I entered INSERT mode.
          >
          > Is there a way to configure vim so that the mouse scroll wheel/middle
          > mouse button is disabled when in INSERT mode?

          The following mappings seem to do the trick:

          inoremap <ScrollWheelUp> <Nop>
          inoremap <ScrollWheelDown> <Nop>

          I found them by typing:

          :help Scroll<C-D>

          and looking on the listed items. <C-D> is Ctrl-D.

          Cheers!
          Israel

          --
          --
          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
          ... Wow! I ll helpgrep next time. Thanks, Marcin -- -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text
          Message 4 of 12 , Jan 25, 2014
          • 0 Attachment
            On 13:46 Sat 25 Jan , Israel Chauca wrote:
            > On 1/24/14, 1:46 PM, Glenn Todd Miller wrote:
            > > Long time vim user looking for some advice on this, tried searching the
            > > web to no avail. I am using CentOS 6 and vim 7.2.411.
            > >
            > > My issue: In vim, I am in INSERT mode, my cursor is where I want it to be
            > > for a PASTE operation, but when I press the middle mouse button (which in
            > > my case is a scroll wheel) to do the paste the wheel moves inadvertently
            > > and I end up pasting somewhere else, not in the place where my cursor
            > > was when I entered INSERT mode.
            > >
            > > Is there a way to configure vim so that the mouse scroll wheel/middle
            > > mouse button is disabled when in INSERT mode?
            >
            > The following mappings seem to do the trick:
            >
            > inoremap <ScrollWheelUp> <Nop>
            > inoremap <ScrollWheelDown> <Nop>
            >
            > I found them by typing:
            >
            > :help Scroll<C-D>
            >
            > and looking on the listed items. <C-D> is Ctrl-D.
            >
            > Cheers!
            > Israel

            Wow! I'll helpgrep next time.

            Thanks,
            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.
          • John Little
            ... I know the OP is on CentOS, but FWIW the mappings don t work on Windows; the mouse wheel handling is hard-coded there. Regards, John Little -- -- You
            Message 5 of 12 , Jan 25, 2014
            • 0 Attachment
              On Sunday, January 26, 2014 7:46:17 AM UTC+13, Israel Chauca F. wrote:

              > The following mappings seem to do the trick...

              I know the OP is on CentOS, but FWIW the mappings don't work on Windows; the mouse wheel handling is hard-coded there.

              Regards, John Little

              --
              --
              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
              ... They work on Linux. Regards, Marcin -- -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text you are
              Message 6 of 12 , Jan 26, 2014
              • 0 Attachment
                On 19:16 Sat 25 Jan , John Little wrote:
                > On Sunday, January 26, 2014 7:46:17 AM UTC+13, Israel Chauca F. wrote:
                >
                > > The following mappings seem to do the trick...
                >
                > I know the OP is on CentOS, but FWIW the mappings don't work on Windows; the mouse wheel handling is hard-coded there.
                >
                > Regards, John Little

                They work on Linux.

                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.
              • Terrance Chen
                在 2014年1月25日星期六UTC+8上午2时46分44秒,Glenn Todd Miller写道: ... my advise is do not use mouse at all -- -- You received this message
                Message 7 of 12 , Jan 26, 2014
                • 0 Attachment
                  在 2014年1月25日星期六UTC+8上午2时46分44秒,Glenn Todd Miller写道:
                  > Long time vim user looking for some advice on this, tried searching the
                  >
                  > web to no avail.  I am using CentOS 6 and vim 7.2.411.
                  >
                  >  
                  >
                  > My issue: In vim, I am in INSERT mode, my cursor is where I want it to be
                  >
                  > for a PASTE operation, but when I press the middle mouse button (which in
                  >
                  > my case is a scroll wheel) to do the paste the wheel moves inadvertently
                  >
                  > and I end up pasting somewhere else, not in the place where my cursor
                  >
                  > was when I entered INSERT mode.
                  >
                  >  
                  >
                  > Is there a way to configure vim so that the mouse scroll wheel/middle
                  >
                  > mouse button is disabled when in INSERT mode?
                  >
                  >  
                  >
                  > Outside of insert mode the mouse scroll is a great feature, so I only
                  >
                  > want to disable it when in insert mode.
                  >
                  > Thanks for any help,
                  >
                  >  
                  >
                  >  
                  >
                  >  
                  my advise is do not use mouse at all

                  --
                  --
                  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.
                • Glenn Todd Miller
                  Thanks for the replies but I am not having luck with the mappings. When I am in INSERT mode the mouse wheel still works. FYI I am in a gnome-terminal when I
                  Message 8 of 12 , Jan 27, 2014
                  • 0 Attachment
                    Thanks for the replies but I am not having luck with the mappings.
                    When I am in INSERT mode the mouse wheel still works.
                    FYI I am in a gnome-terminal when I use vi, although I would not
                    think this should matter.

                    Interestingly I was able to 'disable' the mouse wheel for 'normal' mode only using

                    :nmap <MouseScrollWheelUp> <nop>

                    which looks like this on my screen :nmap ^[OA <nop>
                    and of course the MouseScrollWheelDown (which is ^[OB ) too.

                    Once I executed those 2 nmap commands in my vi session, I could no longer
                    move the cursor with the mouse's scroll wheel. It would be fantastic if
                    I could get this same behavior when I am in insert mode.

                    So next I tried the same technique with all the other 'map' commands,
                    using 'imap' for insert, 'map!', 'vmap', .... etc. And again, the ONLY
                    mode in which the scroll wheel was disabled was the 'normal' mode.

                    Thanks for any suggestions,
                    -Glenn


                    -----Original Message-----
                    From: vim_use@... [mailto:vim_use@...] On Behalf Of Marcin Szamotulski
                    Sent: Sunday, January 26, 2014 5:43 AM
                    To: vim_use@...
                    Subject: Re: How to disable mouse scroll wheel when in insert mode?

                    On 19:16 Sat 25 Jan , John Little wrote:
                    > On Sunday, January 26, 2014 7:46:17 AM UTC+13, Israel Chauca F. wrote:
                    >
                    > > The following mappings seem to do the trick...
                    >
                    > I know the OP is on CentOS, but FWIW the mappings don't work on Windows; the mouse wheel handling is hard-coded there.
                    >
                    > Regards, John Little

                    They work on Linux.

                    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.

                    --
                    --
                    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.
                  • John Little
                    ... That s not right, it s , the word Mouse is not used, but if it worked, I presume that s a mistake in your post. ... I don t understand
                    Message 9 of 12 , Jan 27, 2014
                    • 0 Attachment
                      On Tuesday, January 28, 2014 11:25:27 AM UTC+13, Glenn Todd Miller wrote:
                      > Thanks Vfor the replies but I am not having luck with the mappings.
                      >
                      > When I am in INSERT mode the mouse wheel still works.
                      >
                      > FYI I am in a gnome-terminal when I use vi, although I would not
                      > think this should matter.
                      >
                      > Interestingly I was able to 'disable' the mouse wheel for 'normal' mode only using
                      >
                      > :nmap <MouseScrollWheelUp> <nop>

                      That's not right, it's "<ScrollWheelUp>", the word "Mouse" is not used, but if it worked, I presume that's a mistake in your post.

                      > which looks like this on my screen :nmap ^[OA <nop>
                      > and of course the MouseScrollWheelDown (which is ^[OB ) too.

                      I don't understand that, or what you are doing. It should look exactly like

                      :inoremap <ScrollWheelDown> <nop>
                      :inoremap <ScrollWheelUp> <nop>

                      on your screen, no control sequences. Just fired up gnome-terminal (for the first time in several years, it doesn't play well with KDE) and those exact commands worked.

                      Also, if I use control-V to find what gnome-terminal sends for the scroll wheel I get something like
                      ^[[<65;7;26M
                      and
                      ^[[<64;15;28M

                      (they vary depending on something, maybe the screen position, so you couldn't map them that way).

                      ^[OA and ^[OB are the sequences for up arrow and down arrow. If you are getting those when you use the scroll wheel, then that's your problem, something is changing the scroll actions to arrow key presses. To check that out, in vim in insert mode press ctrl-v then move the scroll wheel one notch.

                      (Interestingly, I checked out xterm and konsole; xterm is the same or similar to gnome-terminal, but konsole sends ^[[M`P6 and ^[[MaP6. What the second and third numbers are in the xterm and gnome-terminal sequences, and how vim sorts it all out, has me perplexed.)

                      Regards, John Little

                      --
                      --
                      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.
                    • Gary Johnson
                      ... When you start gnome-terminal in KDE, does it get narrower in small steps until it is about 20 columns wide? Regards, Gary -- -- You received this message
                      Message 10 of 12 , Jan 27, 2014
                      • 0 Attachment
                        On 2014-01-27, John Little wrote:

                        > Just fired up gnome-terminal (for the first time in several years,
                        > it doesn't play well with KDE) and those exact commands worked.

                        When you start gnome-terminal in KDE, does it get narrower in small
                        steps until it is about 20 columns wide?

                        Regards,
                        Gary

                        --
                        --
                        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.
                      • John Little
                        ... Yes. I gathered that the gnome 3 people say kwin acts on a misinterpretation of some standard, and their way is the only right way to do things. Very
                        Message 11 of 12 , Jan 27, 2014
                        • 0 Attachment
                          On Tuesday, January 28, 2014 2:03:52 PM UTC+13, Gary Johnson wrote:

                          > When you start gnome-terminal in KDE, does it get narrower in small
                          > steps until it is about 20 columns wide?

                          Yes. I gathered that the gnome 3 people say kwin acts on a misinterpretation of some standard, and their way is the only right way to do things. Very Gnome 3-ish. Also, I'm a fan of a 4 or 5 Hz cursor blink, and to persuade gnome-terminal to blink quickly the gnome settings daemon has to be running, and I used to do that, but I couldn't get the Gnome 3 one to run without the rest of Gnome, which I don't want. I found how to quicken the cursor in konsole (it's a qt4 setting) and quite like it now.

                          Regards, John Little

                          --
                          --
                          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.
                        • John Little
                          Glenn Todd Miller replied to my post by e-mail, because he wanted to include screenshots. They demonstrate that he is using ... but as I suggested be checked
                          Message 12 of 12 , Jan 29, 2014
                          • 0 Attachment
                            Glenn Todd Miller replied to my post by e-mail, because he wanted to include screenshots.

                            They demonstrate that he is using

                            :inoremap <ScrollWheelDown> <nop>

                            but as I suggested be checked out, Glenn is getting ^[OA and ^[OB arrow key sequences when the mouse wheel is used.

                            What could be causing this? I have no idea, other than I'm told it's possible using easystroke, an X mouse gesture tool. His CentOS is

                            Red Hat Enterprise Linux Workstation release 6.5 (Santiago)

                            Regards, John Little

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