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

Common mapping for repeating things

Expand Messages
  • Andy Wokula
    We know that the repeat command ... cannot be customized, which is a pity in many occasions. But maybe there are some good reasons to keep the situation as
    Message 1 of 11 , Jan 30, 2008
    • 0 Attachment
      We know that the repeat command
      :h .

      cannot be customized, which is "a pity" in many occasions. But maybe
      there are some good reasons to keep the situation as it is.

      Now what about a convention for script writers to use an additional (but
      common) key for this purpose? I just found that
      g.
      is an unused key, which would be quite intuitive to use.

      Every script would be allowed to map g. for its own purpose. If there
      is a complex action for which repetition is desirable, users can expect
      that g. will repeat it.

      It's pure convention. A help topic
      :h g.

      somewhere below (e.g.)
      :h write-plugin

      could mention that although this key does nothing out of the box, users
      shouldn't map it in their vimrc.

      It would be backwards compatible.

      Just a thought.

      --
      Andy

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • A.Politz
      ... And which plugin gets the honor to map g. ? -ap -- Ich hab geträumt, der Krieg wär vorbei. --~--~---------~--~----~------------~-------~--~----~ You
      Message 2 of 11 , Jan 30, 2008
      • 0 Attachment
        Andy Wokula wrote:

        >We know that the repeat command
        > :h .
        >
        >cannot be customized, which is "a pity" in many occasions. But maybe
        >there are some good reasons to keep the situation as it is.
        >
        >Now what about a convention for script writers to use an additional (but
        >common) key for this purpose? I just found that
        > g.
        >is an unused key, which would be quite intuitive to use.
        >
        >Every script would be allowed to map g. for its own purpose. If there
        >is a complex action for which repetition is desirable, users can expect
        >that g. will repeat it.
        >
        >It's pure convention. A help topic
        > :h g.
        >
        >somewhere below (e.g.)
        > :h write-plugin
        >
        >could mention that although this key does nothing out of the box, users
        >shouldn't map it in their vimrc.
        >
        >It would be backwards compatible.
        >
        >Just a thought.
        >
        >
        >
        And which plugin gets the honor to map 'g.' ?

        -ap

        --
        Ich hab geträumt, der Krieg wär vorbei.


        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Andy Wokula
        ... Hmm, you think this is a silly idea? As said, any plugin. The request for customizable repetition comes up now and then (I should have made a list ...).
        Message 3 of 11 , Jan 30, 2008
        • 0 Attachment
          A.Politz schrieb:
          > Andy Wokula wrote:
          >
          >> We know that the repeat command
          >> :h .
          >>
          >> cannot be customized, which is "a pity" in many occasions. But maybe
          >> there are some good reasons to keep the situation as it is.
          >>
          >> Now what about a convention for script writers to use an additional (but
          >> common) key for this purpose? I just found that
          >> g.
          >> is an unused key, which would be quite intuitive to use.
          >>
          >> Every script would be allowed to map g. for its own purpose. If there
          >> is a complex action for which repetition is desirable, users can expect
          >> that g. will repeat it.
          >>
          >> It's pure convention. A help topic
          >> :h g.
          >>
          >> somewhere below (e.g.)
          >> :h write-plugin
          >>
          >> could mention that although this key does nothing out of the box, users
          >> shouldn't map it in their vimrc.
          >>
          >> It would be backwards compatible.
          >>
          >> Just a thought.
          >>
          > And which plugin gets the honor to map 'g.' ?
          >
          > -ap

          Hmm, you think this is a silly idea? As said, any plugin.

          The request for customizable repetition comes up now and then (I should
          have made a list ...).

          Someone at the vimoutliner-ml asked for repeatable checkbox operations.
          Would be very easy if the script mapped "g.", currently ",,cx" has to
          be typed.

          If "g." is still too long, the user could map any other key (e.g. <F8>)
          to it.

          Via
          :map g.
          the user can easily find out what will be repeated.

          "g." would help surround.vim for some situations, e.g. for repeating
          cs"'
          Don't know if it will help if omap-motions are involved (the script
          probably cannot know the motion provided by the user).

          Long time ago, customizable repeating was requested for the yankring
          plugin.

          Besides the builtin ".", there is "@:" which can be used to repeat the
          last Ex-command, but not if it was triggered by a mapping.

          --
          Andy

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • A.Politz
          ... No, I was to silly to understand. The mapping would be in a state of constant flux as some Trekkie would put it. It would be constantly remapped by
          Message 4 of 11 , Jan 30, 2008
          • 0 Attachment
            Andy Wokula wrote:

            >A.Politz schrieb:
            >
            >
            >>Andy Wokula wrote:
            >>
            >>
            >>
            >>>We know that the repeat command
            >>> :h .
            >>>
            >>>cannot be customized, which is "a pity" in many occasions. But maybe
            >>>there are some good reasons to keep the situation as it is.
            >>>
            >>>Now what about a convention for script writers to use an additional (but
            >>>common) key for this purpose? I just found that
            >>> g.
            >>>is an unused key, which would be quite intuitive to use.
            >>>
            >>>Every script would be allowed to map g. for its own purpose. If there
            >>>is a complex action for which repetition is desirable, users can expect
            >>>that g. will repeat it.
            >>>
            >>>It's pure convention. A help topic
            >>> :h g.
            >>>
            >>>somewhere below (e.g.)
            >>> :h write-plugin
            >>>
            >>>could mention that although this key does nothing out of the box, users
            >>>shouldn't map it in their vimrc.
            >>>
            >>>It would be backwards compatible.
            >>>
            >>>Just a thought.
            >>>
            >>>
            >>>
            >>And which plugin gets the honor to map 'g.' ?
            >>
            >>-ap
            >>
            >>
            >
            >Hmm, you think this is a silly idea? As said, any plugin.
            >
            >
            No, I was to silly to understand. The mapping would be in a
            "state of constant flux" as some Trekkie would put it. It
            would be constantly remapped by different plugins.

            -ap

            >The request for customizable repetition comes up now and then (I should
            >have made a list ...).
            >
            >Someone at the vimoutliner-ml asked for repeatable checkbox operations.
            >Would be very easy if the script mapped "g.", currently ",,cx" has to
            >be typed.
            >
            >If "g." is still too long, the user could map any other key (e.g. <F8>)
            >to it.
            >
            >Via
            > :map g.
            >the user can easily find out what will be repeated.
            >
            >"g." would help surround.vim for some situations, e.g. for repeating
            > cs"'
            >Don't know if it will help if omap-motions are involved (the script
            >probably cannot know the motion provided by the user).
            >
            >Long time ago, customizable repeating was requested for the yankring
            >plugin.
            >
            >Besides the builtin ".", there is "@:" which can be used to repeat the
            >last Ex-command, but not if it was triggered by a mapping.
            >
            >
            >


            --
            Ich hab geträumt, der Krieg wär vorbei.


            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • Thomas Köhler
            Hi Andy, ... When you need a customized repeat, you might want to create a customized macro which you can save in a register and run via @r with r being the
            Message 5 of 11 , Jan 31, 2008
            • 0 Attachment
              Hi Andy,

              Andy Wokula wrote:
              > We know that the repeat command
              > :h .
              >
              > cannot be customized, which is "a pity" in many occasions. But maybe
              > there are some good reasons to keep the situation as it is.

              When you need a customized repeat, you might want to create a
              customized macro which you can save in a register and run via @r
              with r being the registername. Then . works as you might expect,
              so the question might be of how to organize the script so complex
              commands can still be repeated easily...

              Ciao,
              Thomas

              --
              Thomas Köhler Email: jean-luc@...
              <>< WWW: http://gott-gehabt.de
              IRC: tkoehler
              PGP public key available from Homepage!
            • A.Politz
              ... I think it s a good idea. But I don t think Bram adds this to the help files. And it s questionable, whether this becomes popular, by adding it to them.
              Message 6 of 11 , Jan 31, 2008
              • 0 Attachment
                Andy Wokula wrote:

                >A.Politz schrieb:
                >
                >
                >>Andy Wokula wrote:
                >>
                >>
                >>
                >>>We know that the repeat command
                >>> :h .
                >>>
                >>>cannot be customized, which is "a pity" in many occasions. But maybe
                >>>there are some good reasons to keep the situation as it is.
                >>>
                >>>Now what about a convention for script writers to use an additional (but
                >>>common) key for this purpose? I just found that
                >>> g.
                >>>is an unused key, which would be quite intuitive to use.
                >>>
                >>>Every script would be allowed to map g. for its own purpose. If there
                >>>is a complex action for which repetition is desirable, users can expect
                >>>that g. will repeat it.
                >>>
                >>>It's pure convention. A help topic
                >>> :h g.
                >>>
                >>>somewhere below (e.g.)
                >>> :h write-plugin
                >>>
                >>>could mention that although this key does nothing out of the box, users
                >>>shouldn't map it in their vimrc.
                >>>
                >>>It would be backwards compatible.
                >>>
                >>>Just a thought.
                >>>
                >>>
                >>>
                >>And which plugin gets the honor to map 'g.' ?
                >>
                >>-ap
                >>
                >>
                >
                >Hmm, you think this is a silly idea? As said, any plugin.
                >
                >The request for customizable repetition comes up now and then (I should
                >have made a list ...).
                >
                >Someone at the vimoutliner-ml asked for repeatable checkbox operations.
                >Would be very easy if the script mapped "g.", currently ",,cx" has to
                >be typed.
                >
                >If "g." is still too long, the user could map any other key (e.g. <F8>)
                >to it.
                >
                >Via
                > :map g.
                >the user can easily find out what will be repeated.
                >
                >"g." would help surround.vim for some situations, e.g. for repeating
                > cs"'
                >Don't know if it will help if omap-motions are involved (the script
                >probably cannot know the motion provided by the user).
                >
                >Long time ago, customizable repeating was requested for the yankring
                >plugin.
                >
                >Besides the builtin ".", there is "@:" which can be used to repeat the
                >last Ex-command, but not if it was triggered by a mapping.
                >
                >
                >
                I think it's a good idea. But I don't think Bram adds this to the
                help files. And it's questionable, whether this becomes popular, by
                adding it to them. Lately I used a plugin, which uses an '!' to flag
                a modified buffer, while it's conventional to use a '+' since the
                beginning of time. I believe it would more likely become a
                convention by simply people doing it. On the other side, a plugin
                needs the functionality for a complex-repeat first, before it can
                decide which key to map it. I don't know how many actually have such
                an implementation.

                -ap



                --
                Ich hab geträumt, der Krieg wär vorbei.


                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_use" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---
              • Ben Schmidt
                ... As you noted, a request was made a while ago to be able to save the . command for later reuse, e.g. to turn it into a macro without remembering to push
                Message 7 of 11 , Jan 31, 2008
                • 0 Attachment
                  > We know that the repeat command
                  > :h .
                  >
                  > cannot be customized, which is "a pity" in many occasions. But maybe
                  > there are some good reasons to keep the situation as it is.

                  As you noted, a request was made a while ago to be able to save the . command for
                  later reuse, e.g. to turn it into a macro without remembering to push 'record'
                  beforehand. I have made a patch that does this, more or less. It is buggy at
                  present, and Bram has requested it be extended to make the register writable as
                  well. I intend to look into this, and when it is done, it should allow for
                  customising the . command. I haven't had time to work on it recently, but I will
                  get to it before too long, I hope.

                  Ben.



                  Send instant messages to your online friends http://au.messenger.yahoo.com


                  --~--~---------~--~----~------------~-------~--~----~
                  You received this message from the "vim_use" maillist.
                  For more information, visit http://www.vim.org/maillist.php
                  -~----------~----~----~----~------~----~------~--~---
                • Ben Schmidt
                  ... For omaps, there is now v:operator to get the operator. For custom operators using g@ the readable register that is used for the . command (which as I
                  Message 8 of 11 , Jan 31, 2008
                  • 0 Attachment
                    > Don't know if it will help if omap-motions are involved (the script
                    > probably cannot know the motion provided by the user).

                    For omaps, there is now v:operator to get the operator.

                    For custom operators using g@ the readable register that is used for the . command
                    (which as I mentioned I am working on a patch for) allows the motion to be
                    discovered; one can read the register (@,) and everything after the 'g@' will be
                    the motion the user provided. I think this should mostly work, if not always, but
                    only once the patch is finished and gets some use will we really know, I guess.

                    Ben.



                    Send instant messages to your online friends http://au.messenger.yahoo.com


                    --~--~---------~--~----~------------~-------~--~----~
                    You received this message from the "vim_use" maillist.
                    For more information, visit http://www.vim.org/maillist.php
                    -~----------~----~----~----~------~----~------~--~---
                  • Andy Wokula
                    ... ? ... ? Hmm, I don t understand exactly ... For most cases, I expect simple mappings and little effort for the script writer. One of the ideas is to
                    Message 9 of 11 , Jan 31, 2008
                    • 0 Attachment
                      Thomas Köhler schrieb:
                      > Hi Andy,
                      >
                      > Andy Wokula wrote:
                      >> We know that the repeat command
                      >> :h .
                      >>
                      >> cannot be customized, which is "a pity" in many occasions. But maybe
                      >> there are some good reasons to keep the situation as it is.
                      >
                      > When you need a customized repeat, you might want to create a
                      > customized macro which you can save in a register and run via @r
                      > with r being the registername.

                      > Then . works as you might expect,
                      ?

                      > so the question might be of how to organize the script so complex
                      > commands can still be repeated easily...
                      ?
                      Hmm, I don't understand exactly ...

                      For most cases, I expect simple mappings and little effort for the
                      script writer. One of the ideas is to "shorten" a lengthy mapping that
                      the script provides. For example (fictional):

                      :nmap <Leader>ftr <plug>FormatTableRow

                      :nn <plug>FormatTableRow :<c-u>call <sid>FTR(v:count1)<cr>

                      func! <sid>FTR(ncolumns)
                      " format {ncolumns} columns of the current row (= line)
                      ...

                      nmap g. <plug>FormatTableRow
                      endfunc

                      Usage example -- format three rows at different places:
                      23gg \ftr jjj g. jjjjj g.

                      (spaces to be ignored, assuming mapleader not set)

                      The same with macro recording:
                      23gg qr\ftrq jjj @r jjjjj @r

                      Right, only three additional keypresses. But this is only true in
                      theory.

                      Usually you (I mean I) forget to start recording:
                      23gg \ftr jjj

                      ... think "f*** I need to repeat this ..."
                      qr\ftrq jjjjj @r

                      Result: Too many keystrokes, too much thinking (including: do I really
                      need a macro? or is it easier to type \ftr jjjjj \ftr ... ).

                      > Ciao,
                      > Thomas

                      --
                      Andy

                      --~--~---------~--~----~------------~-------~--~----~
                      You received this message from the "vim_use" maillist.
                      For more information, visit http://www.vim.org/maillist.php
                      -~----------~----~----~----~------~----~------~--~---
                    • Ben Schmidt
                      ... I think the idea was along the lines of the following, and that this would be a fairly straightforward way to arrange a script to do it easily: map
                      Message 10 of 11 , Jan 31, 2008
                      • 0 Attachment
                        >> When you need a customized repeat, you might want to create a
                        >> customized macro which you can save in a register and run via @r
                        >> with r being the registername.
                        >
                        >> Then . works as you might expect,
                        > ?
                        >> so the question might be of how to organize the script so complex
                        >> commands can still be repeated easily...
                        > ?
                        > Hmm, I don't understand exactly ...

                        I think the idea was along the lines of the following, and that this would be a
                        fairly straightforward way to arrange a script to do it easily:

                        map <Leader>whatever :call <SID>SetRepeatAndDo('MyOperation')<CR>
                        func! <SID>SetRepeatAndDo(op)
                        let @r=":call \<SID>".op."()\<CR>"
                        normal @r
                        endfunc
                        func! <SID>MyOperation()
                        " do the fancy stuff
                        endfunc

                        supposing then that @r is what is thereafter triggered by the . command.

                        \whatever jjj . jjj . jjjj .

                        Though as mentioned in my earlier posts, there should soon be better solutions to
                        this anyway by means of setting the register for the . command directly.

                        Ben.


                        Send instant messages to your online friends http://au.messenger.yahoo.com


                        --~--~---------~--~----~------------~-------~--~----~
                        You received this message from the "vim_use" maillist.
                        For more information, visit http://www.vim.org/maillist.php
                        -~----------~----~----~----~------~----~------~--~---
                      • Andy Wokula
                        ... Looks as if Tim Pope has found a workaround for the issue: Vimscript #2136 -- Andy --~--~---------~--~----~------------~-------~--~----~ You received this
                        Message 11 of 11 , Jan 31, 2008
                        • 0 Attachment
                          Andy Wokula schrieb:
                          > We know that the repeat command
                          > :h .
                          >
                          > cannot be customized, which is "a pity" in many occasions. But maybe
                          > there are some good reasons to keep the situation as it is.

                          Looks as if Tim Pope has found a workaround for the issue: Vimscript #2136

                          --
                          Andy


                          --~--~---------~--~----~------------~-------~--~----~
                          You received this message from the "vim_use" maillist.
                          For more information, visit http://www.vim.org/maillist.php
                          -~----------~----~----~----~------~----~------~--~---
                        Your message has been successfully submitted and would be delivered to recipients shortly.