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

Why use relative line numbers?

Expand Messages
  • Chris Lott
    The discussion about relative line numbers raises the question (for me): why use relative line numbers at all? The main reason I keep reading is that instead
    Message 1 of 8 , May 29, 2013
    • 0 Attachment
      The discussion about relative line numbers raises the question (for
      me): why use relative line numbers at all?

      The main reason I keep reading is that instead of having to calculate
      how many lines one wants to move and then use, say, 5j to move there
      (or pressing j five times, yuck), one can immediately see that the
      desired line is 5 lines away.

      But if I am on line 7 and see something on another line, I can just
      use 12gg or 12G to get there. And if I have relative numbering on, it
      messes with specifying ranges (as far as I can tell). Does relative
      numbering offer other efficiencies?

      c
      --
      Chris Lott <chris@...>

      --
      --
      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
      ... Yes, also it s useful for things like 5dd (or d4j if you want no math at all). ... It s more distracting if you get to 4 or more digits in the absolute
      Message 2 of 8 , May 29, 2013
      • 0 Attachment
        On Wednesday, May 29, 2013 3:29:59 PM UTC-5, Chris Lott wrote:
        > The discussion about relative line numbers raises the question (for
        > me): why use relative line numbers at all?
        >
        > The main reason I keep reading is that instead of having to calculate
        > how many lines one wants to move and then use, say, 5j to move there
        > (or pressing j five times, yuck), one can immediately see that the
        > desired line is 5 lines away.
        >

        Yes, also it's useful for things like 5dd (or d4j if you want no math at all).

        > But if I am on line 7 and see something on another line, I can just
        > use 12gg or 12G to get there.

        It's more distracting if you get to 4 or more digits in the absolute line
        number. I'd much rather do 3j than 54892G. And sometimes the linewise G/gg
        command doesn't work for what I want anyway (but I can't think of any specific
        examples).

        > And if I have relative numbering on, it
        > messes with specifying ranges (as far as I can tell). Does relative
        > numbering offer other efficiencies?
        >

        You can use relative line numbers in ranges, so no problems there. E.g. replace
        "foo" with "bar" from here to 5 lines down:

        :.,.+5s/foo/bar/g

        You can technically omit the . in most cases for efficiency but it's clearer
        with in my opinion.

        Some commands only work with relative numbers. For example, _ is mostly
        synonymous with ^, but you can give it a count to also move to a different line
        (at the beginning of the line). This count is (mostly) relative.

        Other commands like J which take a count referring to number of lines, but don't
        take motions at all, are more efficient with relative line numbering.

        One unexpected use that I found is that Vim error messages give a line number
        relative to the beginning of a function when a function throws the error.
        Instead of counting lines I can cursor to the top of the function and see
        exactly which line is at fault.

        --
        --
        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.
      • Tim Chase
        ... In small files, the differences are somewhat minor. However if you re down in the bottom of a large file, d5k is considerably shorter than d14159G you can
        Message 3 of 8 , May 29, 2013
        • 0 Attachment
          On 2013-05-29 12:29, Chris Lott wrote:
          > But if I am on line 7 and see something on another line, I can just
          > use 12gg or 12G to get there. And if I have relative numbering on,
          > it messes with specifying ranges (as far as I can tell). Does
          > relative numbering offer other efficiencies?

          In small files, the differences are somewhat minor. However if
          you're down in the bottom of a large file,

          d5k

          is considerably shorter than

          d14159G

          you can pretty much be guaranteed that your relative jump will be
          capped at 2 digits (possibly 3 if your cursor line is at the
          top/bottom of the screen you have a wide-screen monitor in portrait
          mode, giving you more than 100 lines of text).

          It's also just a matter of how your mind thinks.

          -tim


          --
          --
          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
          ben, tim, Can you give this a try again: http://vim-wiki.mawercer.de/wiki/tips/goto-line-by-last-digits.html would using normal line numbers be fine this way
          Message 4 of 8 , May 29, 2013
          • 0 Attachment
            ben, tim,

            Can you give this a try again:
            http://vim-wiki.mawercer.de/wiki/tips/goto-line-by-last-digits.html

            would using normal line numbers be fine this way if it was possible to
            pass 05?

            eg d3\G works now.

            not having relative line numbers is less confusing, because the numbers
            on the left don't change.

            If this would work nicely, would there be a reason to keep relative line
            numbers ?

            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.
          • Ben Fritz
            ... As I mentioned before, J and _ and some other commands are much more useful to me with relative line numbers. And I like using them with dd, cc, yy, etc.
            Message 5 of 8 , May 29, 2013
            • 0 Attachment
              On Wednesday, May 29, 2013 4:46:30 PM UTC-5, MarcWeber wrote:
              > ben, tim,
              >
              >
              >
              > Can you give this a try again:
              >
              > http://vim-wiki.mawercer.de/wiki/tips/goto-line-by-last-digits.html
              >
              >
              >
              > would using normal line numbers be fine this way if it was possible to
              >
              > pass 05?
              >
              >
              >
              > eg d3\G works now.
              >
              >
              >
              > not having relative line numbers is less confusing, because the numbers
              >
              > on the left don't change.
              >
              >
              >
              > If this would work nicely, would there be a reason to keep relative line
              >
              > numbers ?
              >

              As I mentioned before, J and _ and some other commands are much more useful to me with relative line numbers. And I like using them with dd, cc, yy, etc. these days, although I could change that to instead use the absolute numbers if I wanted.

              In the beginning, relative line numbers also frequently took up less space than the absolute line numbers. That's no longer the case (as noted by much recent discussion).

              I like the idea of your plugin and if relative line numbers were not around I'd probably use it. But as it stands now I don't mind sticking with relative numbering.

              The other situation I use relative numbers a lot is when I'm recording macros to do a lot of stuff in a small range of lines. :set rnu can make it easier to get this right on the first try faster.

              --
              --
              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.
            • Christian Brabandt
              Hi Marc! ... Yes. We already have that option and functionality. I don t think, we want to give it away again. regards, Christian -- -- You received this
              Message 6 of 8 , May 29, 2013
              • 0 Attachment
                Hi Marc!

                On Mi, 29 Mai 2013, Marc Weber wrote:

                > If this would work nicely, would there be a reason to keep relative line
                > numbers ?

                Yes. We already have that option and functionality. I don't think, we
                want to give it away again.

                regards,
                Christian

                --
                --
                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
                Well - relative line numbers were introduced to solve a problem (navigating). What do relative line numbers do? + they show you where the cursor is (you could
                Message 7 of 8 , May 29, 2013
                • 0 Attachment
                  Well - relative line numbers were introduced to solve a problem (navigating).

                  What do relative line numbers do?
                  + they show you where the cursor is (you could miss this)
                  + they allow to navigate using less keys

                  issues:
                  - they slow you down. If I open :h having 'relativenumbers' set on 9k is
                  signifcantly slower ! (at least for me having 230 lines)

                  I hope that this is a somewhat accurate description about pro/cons of
                  relativenumbers feature.

                  The alternative I proposed does not suffer from the slowness, and G j k
                  like movements could be made understanding 'lasts digits' only.

                  Anyway if you love it and already have a solution - then go for it.

                  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.
                • Christian Brabandt
                  ... Of course it is, because Vim needs to redraw more often, since the numbers change on almost every move of the cursor. This is also true for
                  Message 8 of 8 , May 29, 2013
                  • 0 Attachment
                    On Do, 30 Mai 2013, Marc Weber wrote:

                    > Well - relative line numbers were introduced to solve a problem (navigating).
                    >
                    > What do relative line numbers do?
                    > + they show you where the cursor is (you could miss this)
                    > + they allow to navigate using less keys
                    >
                    > issues:
                    > - they slow you down. If I open :h having 'relativenumbers' set on 9k is
                    > signifcantly slower ! (at least for me having 230 lines)

                    Of course it is, because Vim needs to redraw more often, since the
                    numbers change on almost every move of the cursor. This is also true for
                    'cursorline'/'cursorcolumn' option.

                    > I hope that this is a somewhat accurate description about pro/cons of
                    > relativenumbers feature.
                    >
                    > The alternative I proposed does not suffer from the slowness, and G j k
                    > like movements could be made understanding 'lasts digits' only.

                    No, because it doesn't work for each use case as has been pointed out,
                    plus it doesn't work reliably (as you also state in your snippet). So it
                    is no complete alternative.

                    > Anyway if you love it and already have a solution - then go for it.

                    In the thread I mentioned, Bram already said, he doesn't like to remove
                    or deprecate options.

                    regards,
                    Christian
                    --
                    Wie viele Jahre Gefängnis entfallen auf die
                    tausendneunhundertsiebenundf√ľnfzig Jahre nach Christus?
                    -- Stanislaw Jerzy Lec (eig. S. J. de Tusch-Letz)

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