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

Re: :set cuc has a side effect of setting the current column

Expand Messages
  • OmnipotentEntity
    On a as expected? That wasn t the behavior I was expecting. Sorry if it was unclear. I expected the cursor to be on e at the end of line because I
    Message 1 of 10 , Mar 18, 2013
      "On "a" as expected?" That wasn't the behavior I was expecting. Sorry if it was unclear. I expected the cursor to be on "e" at the end of "line" because I didn't expect :set cuc to modify the cursor column (because it's not a motion.)

      Having :set cuc modify the cursor column breaks expected cursor positioning if you have a plugin that automatically turns :set cuc on and off. (For instance https://github.com/chreekat/vim-paren-crosshairs ).

      On Monday, March 18, 2013 9:31:27 AM UTC-5, toothpik wrote:
      > On Mon, Mar 18, 2013 at 03:45:22AM -0700, OmnipotentEntity wrote:
      >
      > > Possibly this is a bug, but I'm not sure. Through user fow in #vim on freenode, I've confirmed no side effect in 7.3.409, but there is a side effect in 7.3.547 (the version on my computer) and 7.3.854 according to romainl from stackoverflow.
      >
      >
      >
      > > The easiest way to test is to copy paste the following file into a vim buffer, jump to the beginning (gg) and follow the instructions.
      >
      >
      >
      > > ----
      >
      > > Hi there, this is a test case. I'm the first line.
      >
      > > This line is short.
      >
      > > ----
      >
      >
      >
      > > After opening this file issue the following commands:
      >
      > > $j:set cuc<Enter>k
      >
      >
      >
      > > You'll notice that the cursor should be on the period after "case" this is expected behavior.
      >
      >
      >
      > > Next enter the following commands:
      >
      > > :set nocuc<Enter>$hj:set cuc<Enter>k
      >
      >
      >
      > > You'll notice that the cursor should now be on the word "a" rather than on the "e" at the end of "line"
      >
      >
      >
      > > So when you have a column value (not end of line) then :set cuc modifies this value as a side effect.
      >
      >
      >
      > > Is there anyway to workaround this issue? Is this a bug? Can anyone else reproduce?
      >
      >
      >
      > not here (7.3.865) -- my cursor winds up on the 'a', as expected

      --
      --
      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.
    • Charles Campbell
      ... I used vim -u NONE -N filename with the filename having the contents you specified. Did the $k, so the cursor ends up on . in the second line. Upon
      Message 2 of 10 , Mar 18, 2013
        OmnipotentEntity wrote:
        > "On "a" as expected?" That wasn't the behavior I was expecting. Sorry if it was unclear. I expected the cursor to be on "e" at the end of "line" because I didn't expect :set cuc to modify the cursor column (because it's not a motion.)
        >
        > Having :set cuc modify the cursor column breaks expected cursor positioning if you have a plugin that automatically turns :set cuc on and off. (For instance https://github.com/chreekat/vim-paren-crosshairs ).
        >
        I used vim -u NONE -N filename

        with the filename having the contents you specified. Did the $k, so the
        cursor ends up on "." in the second line.

        Upon doing :set cuc , the vertical line including the "a" and the "."
        is highlighting. The cursor is still on the ".", too.

        That seems to be what I'd expect should happen so far.

        Next: k

        Results in cursor on the first line's "." just after the "first line."
        text. This is also what I'd expect given the default option sol=1
        value. This behavior appears to differ from what you observed.

        So, I moved the cursor to the "." in the text "case."

        Next: $hj moved the cursor to the "." in the second line.

        Next: set cuc<enter> k

        This ended up with the cursor on "a". Again, this is what I'd expect --
        because the cursor got onto the "." via a vertical move, not a "$".

        Perhaps you'd prefer to use "set ve=all"?

        Regards,
        C Campbell



        --
        --
        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.
      • Ben Fritz
        ... No, this is wrong. Try it without the :set cuc and you ll see that the cursor moves back to the end of the word line where it started. With the :set
        Message 3 of 10 , Mar 18, 2013
          On Monday, March 18, 2013 2:18:57 PM UTC-5, Charles Campbell wrote:
          > Next: $hj moved the cursor to the "." in the second line.
          > Next: set cuc<enter> k
          >
          > This ended up with the cursor on "a". Again, this is what I'd expect --
          > because the cursor got onto the "." via a vertical move, not a "$".
          >

          No, this is wrong. Try it without the ":set cuc" and you'll see that the cursor moves back to the end of the word "line" where it started. With the ":set cuc" the cursor moves to the "a" above the end of the second line. Vim seems to be forgetting where it's desired cursor column is.

          --
          --
          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.
        • Christian Brabandt
          Hi Ben! ... That is because certain options reset curwin- w_set_curswant (all options that have the redraw flags P_RSTAT, P_RWIN, P_RBUF, P_RALL, P_RCLR). My
          Message 4 of 10 , Mar 18, 2013
            Hi Ben!

            On Mo, 18 Mär 2013, Ben Fritz wrote:

            > On Monday, March 18, 2013 2:18:57 PM UTC-5, Charles Campbell wrote:
            > > Next: $hj moved the cursor to the "." in the second line.
            > > Next: set cuc<enter> k
            > >
            > > This ended up with the cursor on "a". Again, this is what I'd expect --
            > > because the cursor got onto the "." via a vertical move, not a "$".
            > >
            >
            > No, this is wrong. Try it without the ":set cuc" and you'll see that the cursor moves back to the end of the word "line" where it started. With the ":set cuc" the cursor moves to the "a" above the end of the second line. Vim seems to be forgetting where it's desired cursor column is.

            That is because certain options reset curwin->w_set_curswant (all
            options that have the redraw flags P_RSTAT, P_RWIN, P_RBUF, P_RALL,
            P_RCLR). My guess is, that this is some vi-compatible thing.

            This also happens for e.g. :set nu

            Mit freundlichen Grüßen
            Christian
            --
            Es ist lange her, daß sich die menschliche Phantasie die Hölle
            ausgemalt hat, aber erst durch ihre jüngst erworbenen Fertigkeiten ist
            sie in die Lage versetzt worden, ihre einstigen Vorstellungen zu
            verwirklichen.
            -- Bertrand A. W. Russell

            --
            --
            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.
          • Charles Campbell
            ... However, the OP did say to do the :set cuc , unless that s not what he meant to say. ... norm! $j set cuc norm! k set nocuc norm! $hj set cuc norm !k ...
            Message 5 of 10 , Mar 18, 2013
              Ben Fritz wrote:
              > On Monday, March 18, 2013 2:18:57 PM UTC-5, Charles Campbell wrote:
              >> Next: $hj moved the cursor to the "." in the second line.
              >> Next: set cuc<enter> k
              >>
              >> This ended up with the cursor on "a". Again, this is what I'd expect --
              >> because the cursor got onto the "." via a vertical move, not a "$".
              >>
              > No, this is wrong. Try it without the ":set cuc" and you'll see that the cursor moves back to the end of the word "line" where it started. With the ":set cuc" the cursor moves to the "a" above the end of the second line. Vim seems to be forgetting where it's desired cursor column is.
              >
              However, the OP did say to do the ":set cuc", unless that's not what he
              meant to say.
              Here's a short command file doing what the OP specified:
              --------cmdfile.vim--------
              norm! $j
              set cuc
              norm! k
              set nocuc
              norm! $hj
              set cuc
              norm !k
              --------------------------------

              vim -u NONE -N textfile -S cmdfile.vim

              yields the cursor ending up on the "a". FWIW, commenting out the "set
              cuc" still ends up with the cursor on the "a" (vim 7.3.861).

              I suspect that what is showing up is the difference between using "$" to
              move to the end of line and simply moving to the end of line with hjkl
              (etc). The cursor moves to the same location, but there's a
              difference. You can see it with (assuming the OP's example file):

              vim -u NONE -N textfile

              ---
              norm! G$k
              ---

              versus

              ---
              norm! G$hlk
              ---

              In the first case, the cursor ends up on the "." at the end-of-line. In
              the second case, the cursor ends up on the "a" in the line above.

              Regards,
              C Campbell


              --
              --
              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.
            • Christian Brabandt
              Hi ... (and also in nvi) regards, Christian -- Die Streichung des §218 ist eine Voraussetzung für die Befreiung der Frauen. -- Mitglieder des Frauenbundes
              Message 6 of 10 , Mar 18, 2013
                Hi

                On Mo, 18 Mär 2013, Christian Brabandt wrote:

                > Hi Ben!
                >
                > On Mo, 18 Mär 2013, Ben Fritz wrote:
                >
                > > On Monday, March 18, 2013 2:18:57 PM UTC-5, Charles Campbell wrote:
                > > > Next: $hj moved the cursor to the "." in the second line.
                > > > Next: set cuc<enter> k
                > > >
                > > > This ended up with the cursor on "a". Again, this is what I'd expect --
                > > > because the cursor got onto the "." via a vertical move, not a "$".
                > > >
                > >
                > > No, this is wrong. Try it without the ":set cuc" and you'll see that the cursor moves back to the end of the word "line" where it started. With the ":set cuc" the cursor moves to the "a" above the end of the second line. Vim seems to be forgetting where it's desired cursor column is.
                >
                > That is because certain options reset curwin->w_set_curswant (all
                > options that have the redraw flags P_RSTAT, P_RWIN, P_RBUF, P_RALL,
                > P_RCLR). My guess is, that this is some vi-compatible thing.
                >
                > This also happens for e.g. :set nu

                (and also in nvi)

                regards,
                Christian
                --
                Die Streichung des §218 ist eine Voraussetzung für die Befreiung
                der Frauen.
                -- Mitglieder des Frauenbundes Westberlin, 6. Juni 1971

                --
                --
                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.
              • OmnipotentEntity
                ... Last line should be norm! k Anyway, testing out with the set cuc and set nocuc specified yields different behavior from with those 3 lines commented out.
                Message 7 of 10 , Mar 18, 2013
                  On Monday, March 18, 2013 3:41:00 PM UTC-5, Charles Campbell wrote:
                  > Ben Fritz wrote:
                  >
                  > > On Monday, March 18, 2013 2:18:57 PM UTC-5, Charles Campbell wrote:
                  >
                  > >> Next: $hj moved the cursor to the "." in the second line.
                  >
                  > >> Next: set cuc<enter> k
                  >
                  > >>
                  >
                  > >> This ended up with the cursor on "a". Again, this is what I'd expect --
                  >
                  > >> because the cursor got onto the "." via a vertical move, not a "$".
                  >
                  > >>
                  >
                  > > No, this is wrong. Try it without the ":set cuc" and you'll see that the cursor moves back to the end of the word "line" where it started. With the ":set cuc" the cursor moves to the "a" above the end of the second line. Vim seems to be forgetting where it's desired cursor column is.
                  >
                  > >
                  >
                  > However, the OP did say to do the ":set cuc", unless that's not what he
                  >
                  > meant to say.
                  >
                  > Here's a short command file doing what the OP specified:
                  >
                  > --------cmdfile.vim--------
                  >
                  > norm! $j
                  >
                  > set cuc
                  >
                  > norm! k
                  >
                  > set nocuc
                  >
                  > norm! $hj
                  >
                  > set cuc
                  >
                  > norm !k
                  >
                  > --------------------------------
                  >
                  >
                  >
                  > vim -u NONE -N textfile -S cmdfile.vim
                  >
                  >
                  >
                  > yields the cursor ending up on the "a". FWIW, commenting out the "set
                  >
                  > cuc" still ends up with the cursor on the "a" (vim 7.3.861).
                  >
                  >
                  >
                  > I suspect that what is showing up is the difference between using "$" to
                  >
                  > move to the end of line and simply moving to the end of line with hjkl
                  >
                  > (etc). The cursor moves to the same location, but there's a
                  >
                  > difference. You can see it with (assuming the OP's example file):
                  >
                  >
                  >
                  > vim -u NONE -N textfile
                  >
                  >
                  >
                  > ---
                  >
                  > norm! G$k
                  >
                  > ---
                  >
                  >
                  >
                  > versus
                  >
                  >
                  >
                  > ---
                  >
                  > norm! G$hlk
                  >
                  > ---
                  >
                  >
                  >
                  > In the first case, the cursor ends up on the "." at the end-of-line. In
                  >
                  > the second case, the cursor ends up on the "a" in the line above.
                  >
                  >
                  >
                  > Regards,
                  >
                  > C Campbell

                  Slight typo in your vim command file:

                  > --------cmdfile.vim--------
                  >
                  > norm! $j
                  >
                  > set cuc
                  >
                  > norm! k
                  >
                  > set nocuc
                  >
                  > norm! $hj
                  >
                  > set cuc
                  >
                  > norm !k
                  >
                  > --------------------------------

                  Last line should be norm! k

                  Anyway, testing out with the set cuc and set nocuc specified yields different behavior from with those 3 lines commented out. (Aside from the obvious difference in column highlighting.

                  This behavior is also reproducible using "set cul", "set nocuc", and "set nocul".

                  --
                  --
                  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.
                • Christian Brabandt
                  ... I already wrote, what is causing this. Didn t you get that message? The problem is, that certain options set curwin- w_set_curswant (and this is consistent
                  Message 8 of 10 , Mar 19, 2013
                    On Mon, March 18, 2013 23:23, OmnipotentEntity wrote:
                    >
                    > Anyway, testing out with the set cuc and set nocuc specified yields
                    > different behavior from with those 3 lines commented out. (Aside from the
                    > obvious difference in column highlighting.
                    >
                    > This behavior is also reproducible using "set cul", "set nocuc", and "set
                    > nocul".

                    I already wrote, what is causing this. Didn't you get that message?

                    The problem is, that certain options set curwin->w_set_curswant
                    (and this is consistent with other vi clones), so I wouldn't call
                    this a bug here.


                    regards,
                    Christian

                    --
                    --
                    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.
                  Your message has been successfully submitted and would be delivered to recipients shortly.