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

Re: Making vim not spuriously undo lots of changes

Expand Messages
  • Bram Moolenaar
    ... What terminal is that? -- hundred-and-one symptoms of being an internet addict: 113. You are asked about a bus schedule, you wonder if it is 16 or 32 bits.
    Message 1 of 10 , Aug 22, 2013
    • 0 Attachment
      Paul Evans wrote:

      > In accordance with terminal standards, my terminal sends modified
      > Unicode that doesn't have any other representation (such as
      > Ctrl-Shift-P) using CSI u encoding; for example
      >
      > <C-S-P> == CSI 80;5 u
      >
      > Unfortunately vim doesn't understand this, getting as far as the Escape
      > part of the CSI, treating it as
      >
      > Esc [ 80 ; 5 u
      >
      > causing vim to leave insert mode, start a [ movement that's then
      > aborted, then undo the previous 5 changes. Not helpful.
      >
      > Currently I have something of a bit of a hack in my .vimrc to handle a
      > few of the more common ones by programatically generating a large list
      > of map/imap commands; for example, the handler for Space:
      >
      > <Esc>[32;8u <C-S- >
      > <Esc>[32;7u <C- >
      > <Esc>[32;6u <C-S-Space>
      > <Esc>[32;5u <C-Space>
      > <Esc>[32;4u <S- >
      > <Esc>[32;3u  
      > <Esc>[32;2u <S-Space>
      >
      > However, I believe we can all agree this is unsustainable, as I don't
      > want to have to store a map and an imap command 7 times for each of the
      > ~60-odd Unicode keys I could type.
      >
      > Instead does anyone have a better idea here?

      What terminal is that?

      --
      hundred-and-one symptoms of being an internet addict:
      113. You are asked about a bus schedule, you wonder if it is 16 or 32 bits.

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ an exciting new programming language -- http://www.Zimbu.org ///
      \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

      --
      --
      You received this message from the "vim_dev" 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_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • PaulLeoNerd Evans
      On Thu, 22 Aug 2013 23:07:14 +0200 ... Primarily, my pangoterm (https://launchpad.net/pangoterm), built atop libvterm (https://launchpad.net/libvterm). It can
      Message 2 of 10 , Aug 31, 2013
      • 0 Attachment
        On Thu, 22 Aug 2013 23:07:14 +0200
        Bram Moolenaar <Bram@...> wrote:

        > > In accordance with terminal standards, my terminal sends modified
        > > Unicode that doesn't have any other representation (such as
        > > Ctrl-Shift-P) using CSI u encoding; for example
        > >
        > > <C-S-P> == CSI 80;5 u

        > What terminal is that?

        Primarily, my pangoterm (https://launchpad.net/pangoterm), built atop
        libvterm (https://launchpad.net/libvterm).

        It can also be reproduced by recent xterms, though the encoding model
        there is still somewhat incorrect and non-ideal(!)

        --
        Paul "LeoNerd" Evans

        leonerd@...
        ICQ# 4135350 | Registered Linux# 179460
        http://www.leonerd.org.uk/

        --
        --
        You received this message from the "vim_dev" 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_dev" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Tony Mechelynck
        ... Do you have a proper termcap/terminfo for that terminal? Is $TERM (and term ) set to a correct value? See also ... It seems that the builtin terminals
        Message 3 of 10 , Aug 31, 2013
        • 0 Attachment
          On 22/08/13 18:24, Paul LeoNerd Evans wrote:
          > In accordance with terminal standards, my terminal sends modified
          > Unicode that doesn't have any other representation (such as
          > Ctrl-Shift-P) using CSI u encoding; for example
          >
          > <C-S-P> == CSI 80;5 u
          >
          > Unfortunately vim doesn't understand this, getting as far as the Escape
          > part of the CSI, treating it as
          >
          > Esc [ 80 ; 5 u
          >
          > causing vim to leave insert mode, start a [ movement that's then
          > aborted, then undo the previous 5 changes. Not helpful.
          >
          > Currently I have something of a bit of a hack in my .vimrc to handle a
          > few of the more common ones by programatically generating a large list
          > of map/imap commands; for example, the handler for Space:
          >
          > <Esc>[32;8u <C-S- >
          > <Esc>[32;7u <C- >
          > <Esc>[32;6u <C-S-Space>
          > <Esc>[32;5u <C-Space>
          > <Esc>[32;4u <S- >
          > <Esc>[32;3u
          > <Esc>[32;2u <S-Space>
          >
          > However, I believe we can all agree this is unsustainable, as I don't
          > want to have to store a map and an imap command 7 times for each of the
          > ~60-odd Unicode keys I could type.
          >
          > Instead does anyone have a better idea here?
          >

          Do you have a proper termcap/terminfo for that terminal? Is $TERM (and
          'term') set to a correct value? See also

          :help 'ttybuiltin'
          :help 'esckeys'
          :help 'timeout'
          :help 'ttimeout'
          :help 'timeoutlen'
          :help 'ttimeoutlen'

          It seems that the builtin terminals (when compiled with ++builtin_terms,
          and at least on the Vim 7.4.16 version for Linux I'm using) are

          builtin_amiga
          builtin_beos-ansi
          builtin_ansi
          builtin_pcansi
          builtin_win32
          builtin_vt320
          builtin_vt52
          builtin_xterm
          builtin_iris-ansi
          builtin_debug

          plus the builtin_gui used unchangeably for gvim.

          The workaround, I suppose, would be using Ctrl-P etc. without the Shift
          modifier, which would (hopefully) give the ASCII values for the control
          keys known to ASCII (0x01 for Ctrl-a, 0x02 for Ctrl-b, 0x10 for Ctrl-p,
          etc.), but of course, for use as a mapping {lhs}, it would collide with
          many buit-in key bindings (e.g. Ctrl-P is by default synonymous with
          <Up> or k in Normal mode, so there it isn't a great loss, but in Insert
          mode Ctrl-N and Ctrl-P mean next/previous completion using 'complete' so
          you would have to look out if that's a use case you're interested in).

          Best regards,
          Tony.
          --
          DON'T go!! I'm not HOWARD COSELL!! I know POLISH JOKES ... WAIT!!
          Don't go!! I AM Howard Cosell! ... And I DON'T know Polish jokes!!

          --
          --
          You received this message from the "vim_dev" 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_dev" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • PaulLeoNerd Evans
          On Sat, 31 Aug 2013 19:21:28 +0200 ... TERM=xterm, as it should be for this terminal. It s an xterm :) terminfo/termcap are all set right. But neither terminfo
          Message 4 of 10 , Sep 7, 2013
          • 0 Attachment
            On Sat, 31 Aug 2013 19:21:28 +0200
            Tony Mechelynck <antoine.mechelynck@...> wrote:

            > Do you have a proper termcap/terminfo for that terminal? Is $TERM
            > (and 'term') set to a correct value? See also
            >
            > :help 'ttybuiltin'
            > :help 'esckeys'
            > :help 'timeout'
            > :help 'ttimeout'
            > :help 'timeoutlen'
            > :help 'ttimeoutlen'

            TERM=xterm, as it should be for this terminal. It's an xterm :)

            terminfo/termcap are all set right. But neither terminfo nor termcap
            knows about these key encodings, as this encoding is newer than 10 years
            old :P

            ttybuiltin
            esckeys
            timeout
            nottimeout
            timeoutlen=50
            ttimeoutlen=-1

            > The workaround, I suppose, would be using Ctrl-P etc. without the
            > Shift modifier, which would (hopefully) give the ASCII values for the
            > control keys known to ASCII (0x01 for Ctrl-a, 0x02 for Ctrl-b, 0x10
            > for Ctrl-p, etc.), but of course, for use as a mapping {lhs}, it
            > would collide with many buit-in key bindings (e.g. Ctrl-P is by
            > default synonymous with <Up> or k in Normal mode, so there it isn't a
            > great loss, but in Insert mode Ctrl-N and Ctrl-P mean next/previous
            > completion using 'complete' so you would have to look out if that's a
            > use case you're interested in).

            It's not so much that I -intend- to press e.g. Ctrl-Shift-P a lot. It's
            that sometimes I'll accidentally still have the Shift key held down
            when I hit some other Ctrl-letter key combination. Quite often I
            -accidentally- hit Ctrl-Shift-N instead of Ctrl-N for omnicomplete.

            The trouble here is that vim doesn't just go "beep" to tell me of an
            unrecognised key. It sees

            ESC [ 78;5u

            causing it to leave insert mode (ESC), start a [ motion that then gets
            aborted on seeing the 7, accumulates 8 as the count for the ; motion,
            then accumulates 5 as the count for 'u', resulting in it undoing the
            previous 5 edits I have just been making in insert mode.

            I'd really prefer it not do that :)

            Short of -actually- hacking the terminal input byte parser, is there
            any way around this?

            Failing that, where is the terminal input byte parser (file and line
            number) so I can send you a patch to at least have this encoding not
            perform this stupid undo action, and instead do something a little more
            sensible.

            --
            Paul "LeoNerd" Evans

            leonerd@...
            ICQ# 4135350 | Registered Linux# 179460
            http://www.leonerd.org.uk/
          • John Little
            ... My xterm XTerm(278) doesn t do that; ctrl-shift-p gives the same as ctrl-p. Regards, John Little -- -- You received this message from the vim_dev
            Message 5 of 10 , Sep 8, 2013
            • 0 Attachment
              On Sunday, September 8, 2013 7:29:21 AM UTC+12, Paul Evans wrote:
              > TERM=xterm, as it should be for this terminal. It's an xterm :)

              My xterm "XTerm(278)" doesn't do that; ctrl-shift-p gives the same as ctrl-p.

              Regards, John Little

              --
              --
              You received this message from the "vim_dev" 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_dev" group.
              To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
              For more options, visit https://groups.google.com/groups/opt_out.
            • PaulLeoNerd Evans
              On Sun, 8 Sep 2013 01:37:47 -0700 (PDT) ... See previous comment about it having to be configured to do that, and in any case that xterm itself doesn t do it
              Message 6 of 10 , Sep 20, 2013
              • 0 Attachment
                On Sun, 8 Sep 2013 01:37:47 -0700 (PDT)
                John Little <John.B.Little@...> wrote:

                > My xterm "XTerm(278)" doesn't do that; ctrl-shift-p gives the same as
                > ctrl-p.

                See previous comment about it having to be configured to do that, and
                in any case that xterm itself doesn't do it right anyway - it's too
                eager to use CSI u encoding and then even CSI u encodes plain Ctrl-P.

                --
                Paul "LeoNerd" Evans

                leonerd@...
                ICQ# 4135350 | Registered Linux# 179460
                http://www.leonerd.org.uk/
              • PaulLeoNerd Evans
                On Thu, 22 Aug 2013 17:24:15 +0100 ... Do I take from the relative silence in this thread then that nobody actually has a better idea after all? I may be
                Message 7 of 10 , Sep 20, 2013
                • 0 Attachment
                  On Thu, 22 Aug 2013 17:24:15 +0100
                  Paul "LeoNerd" Evans <leonerd@...> wrote:

                  > However, I believe we can all agree this is unsustainable, as I don't
                  > want to have to store a map and an imap command 7 times for each of
                  > the ~60-odd Unicode keys I could type.
                  >
                  > Instead does anyone have a better idea here?

                  Do I take from the relative silence in this thread then that nobody
                  actually has a better idea after all?

                  I may be forced to consider fixing the source, then.

                  --
                  Paul "LeoNerd" Evans

                  leonerd@...
                  ICQ# 4135350 | Registered Linux# 179460
                  http://www.leonerd.org.uk/
                • Ben Fritz
                  ... Are you able to do a loop to build up such mappings as strings to :execute? That would be nicer than individually doing 7*60 mappings. -- -- You received
                  Message 8 of 10 , Sep 20, 2013
                  • 0 Attachment
                    On Friday, September 20, 2013 7:30:49 AM UTC-5, Paul Evans wrote:
                    > On Thu, 22 Aug 2013 17:24:15 +0100
                    >
                    > Paul "LeoNerd" Evans <leonerd@...> wrote:
                    >
                    >
                    >
                    > > However, I believe we can all agree this is unsustainable, as I don't
                    >
                    > > want to have to store a map and an imap command 7 times for each of
                    >
                    > > the ~60-odd Unicode keys I could type.
                    >
                    > >
                    >
                    > > Instead does anyone have a better idea here?
                    >
                    >
                    >
                    > Do I take from the relative silence in this thread then that nobody
                    >
                    > actually has a better idea after all?
                    >
                    >
                    >
                    > I may be forced to consider fixing the source, then.
                    >
                    >

                    Are you able to do a loop to build up such mappings as strings to :execute? That would be nicer than individually doing 7*60 mappings.

                    --
                    --
                    You received this message from the "vim_dev" 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_dev" group.
                    To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
                    For more options, visit https://groups.google.com/groups/opt_out.
                  • PaulLeoNerd Evans
                    On Fri, 20 Sep 2013 07:15:35 -0700 (PDT) ... Not really. I mean, that s what I do right now and it s horrible. In practice it might not be quite so bad but
                    Message 9 of 10 , Sep 20, 2013
                    • 0 Attachment
                      On Fri, 20 Sep 2013 07:15:35 -0700 (PDT)
                      Ben Fritz <fritzophrenic@...> wrote:

                      > Are you able to do a loop to build up such mappings as strings
                      > to :execute? That would be nicer than individually doing 7*60
                      > mappings.

                      Not really. I mean, that's what I do right now and it's horrible.

                      In practice it might not be quite so bad but that's still a huge number
                      of mappings.

                      Plus, these things aren't really static strings; they are encodings.
                      All these things should mean the same thing

                      CSI 65 ; 1 u
                      CSI 000065; 00001 u
                      CSI 00065;0001;000000;00000235 u
                      etc...

                      They're a protocol encoding information about a keypress; not simple
                      static strings. I'd much prefer that vim's input system could
                      -understand- these as being real CSI sequences and pull them apart
                      properly, than just store a huge static string database.

                      --
                      Paul "LeoNerd" Evans

                      leonerd@...
                      ICQ# 4135350 | Registered Linux# 179460
                      http://www.leonerd.org.uk/
                    Your message has been successfully submitted and would be delivered to recipients shortly.