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

function virtcol() doesn't return the expected value

Expand Messages
  • H Xu
    Hi, The attachment is a picture which shows the cursor position. The cursor at the begin of the second to of line 1247 of editing.txt, which is a help file
    Message 1 of 4 , Dec 2, 2010
    • 0 Attachment
      Hi,

      The attachment is a picture which shows the cursor position.
      The cursor at the begin of the second "to" of line 1247 of
      editing.txt, which is a help file of vim.
      Then use ":echo virtcol('.')".
      While the expected value is 58, it shows 60.

      Is this my mistake or vim has done something wrong? Thanks.

      Regards,
      Hong Xu
      2010/12/2

      --
      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
    • Dominique Pellé
      ... I think that s the expected behavior. There are 2 concealed characters on line 1247. Conceal feature affects how the line is displayed but not the return
      Message 2 of 4 , Dec 2, 2010
      • 0 Attachment
        H Xu wrote:

        > Hi,
        >
        > The attachment is a picture which shows the cursor position.
        > The cursor at the begin of the second "to" of line 1247 of
        > editing.txt, which is a help file of vim.
        > Then use ":echo virtcol('.')".
        > While the expected value is 58, it shows 60.
        >
        > Is this my mistake or vim has done something wrong? Thanks.

        I think that's the expected behavior. There are 2 concealed
        characters on line 1247. Conceal feature affects how the
        line is displayed but not the return value of functions such
        as virtcol('.').

        You can show the concealed char with: :set conceallevel=0

        -- Dominique

        --
        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
      • Christian Brabandt
        ... I have not yet looked into concealing in detail. But is it expected, that moving the cursor over concealed chars takes them into account? ... 1247 norm!
        Message 3 of 4 , Dec 2, 2010
        • 0 Attachment
          On Thu, December 2, 2010 11:48 pm, Dominique Pellé wrote:
          > I think that's the expected behavior. There are 2 concealed
          > characters on line 1247. Conceal feature affects how the
          > line is displayed but not the return value of functions such
          > as virtcol('.').
          >
          > You can show the concealed char with: :set conceallevel=0

          I have not yet looked into concealing in detail. But is it expected,
          that moving the cursor over concealed chars takes them into account?
          For example:
          :h editing.txt
          1247
          norm! 53|
          norm! 2l

          Note, that you need to press "l" 2 times for moving the cursor 2 chars
          to the right, but it actually moves the cursor only one cell to the right.
          I can understand, why this is done, but it seeems a little bit unexpected.

          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
        • H Xu
          ... Hello, I think concealed characters should not be taken into account. The document of virtcol() says: The result is a Number, which is the screen column
          Message 4 of 4 , Dec 3, 2010
          • 0 Attachment
            On 12/03/2010 03:23 PM, Christian Brabandt wrote:
            > On Thu, December 2, 2010 11:48 pm, Dominique Pellé wrote:
            >> I think that's the expected behavior. There are 2 concealed
            >> characters on line 1247. Conceal feature affects how the
            >> line is displayed but not the return value of functions such
            >> as virtcol('.').
            >>
            >> You can show the concealed char with: :set conceallevel=0
            >
            > I have not yet looked into concealing in detail. But is it expected,
            > that moving the cursor over concealed chars takes them into account?
            > For example:
            > :h editing.txt
            > 1247
            > norm! 53|
            > norm! 2l
            >
            > Note, that you need to press "l" 2 times for moving the cursor 2 chars
            > to the right, but it actually moves the cursor only one cell to the right.
            > I can understand, why this is done, but it seeems a little bit unexpected.
            >
            > regards,
            > Christian
            >
            Hello,

            I think concealed characters should not be taken into account. The
            document of virtcol() says:
            " The result is a Number, which is the screen column of the file
            position given with {expr}."

            A screen column should be returned, so virtcol() should not take the
            concealed characters into account.

            Regards,
            Hong Xu
            12/04/2010

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