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

surrparen

Expand Messages
  • AOYAMA Shotaro
    Hi, Now I m writing a plugin that hilights a pair of parens/braces which surround the cursor position. Unlike matchparen.vim, it works even when the cursor is
    Message 1 of 3 , Jan 2, 2007
    • 0 Attachment
      Hi,

      Now I'm writing a plugin that hilights a pair of
      parens/braces which surround the cursor position.
      Unlike matchparen.vim, it works even when the cursor
      is not just on a paren/brace.
      The attached file is the source.

      But I have noticed a bothering problem with it.

      When cursor is on '0' in the following text,
      |
      v
      do_all = (flags[0] == 'g');

      do_all = (flags[1] == 'g');

      you press jj, then the cursor normally should down
      two lines and on '1'.
      But when using this plugin, it goes the first column.

      I'm wondering how I can avoid this problem.
      Any ideas?
      and any other suggestion is welcome.

      Regards,

      --
      AOYAMA Shotaro
      mailto:jod@...
    • Gary Johnson
      ... Does your plugin use the CursorHold or CursorMoved autocommand? Does your plugin move the cursor after the user has moved it, then restore the user s
      Message 2 of 3 , Jan 2, 2007
      • 0 Attachment
        On 2007-01-02, AOYAMA Shotaro <jod@...> wrote:
        > Hi,
        >
        > Now I'm writing a plugin that hilights a pair of
        > parens/braces which surround the cursor position.
        > Unlike matchparen.vim, it works even when the cursor
        > is not just on a paren/brace.
        > The attached file is the source.
        >
        > But I have noticed a bothering problem with it.
        >
        > When cursor is on '0' in the following text,
        > |
        > v
        > do_all = (flags[0] == 'g');
        >
        > do_all = (flags[1] == 'g');
        >
        > you press jj, then the cursor normally should down
        > two lines and on '1'.
        > But when using this plugin, it goes the first column.
        >
        > I'm wondering how I can avoid this problem.
        > Any ideas?
        > and any other suggestion is welcome.

        Does your plugin use the CursorHold or CursorMoved autocommand?
        Does your plugin move the cursor after the user has moved it, then
        restore the user's cursor position?

        Normally, vim remembers that your cursor was in column 17 (over the
        'O') when you moved it to the empty line and moves the cursor back
        to column 17 when you move it again to the next line having 17 or
        more columns. If, when the cursor is at the first column of that
        blank line, your plugin executes a command that remembers the cursor
        position, moves the cursor someplace else, then restores the cursor
        position, vim thinks the user has deliberately moved the cursor to
        column 1 and uses that "desired column number" when the user
        subsequently moves the cursor to the next line. This leaves the
        cursor in column 1 when you think it should have moved back to
        column 17.

        I think this problem can be solved by using the winsaveview()
        function to save the cursor and view information before moving the
        cursor, then using the winrestview() function to restore the cursor
        and view. These functions are new with vim 7.0 and I haven't tried
        them yet.

        HTH,
        Gary

        --
        Gary Johnson | Agilent Technologies
        garyjohn@... | Wireless Division
        | Spokane, Washington, USA
      • AOYAMA Shotaro
        ... Yes, I use CursorMoved autocommand and winsaveview() to save the view information. I have tried the plugin on vim with the newest patches and with options
        Message 3 of 3 , Jan 3, 2007
        • 0 Attachment
          Gary Johnson wrote:
          >Does your plugin use the CursorHold or CursorMoved autocommand?
          >Does your plugin move the cursor after the user has moved it, then
          >restore the user's cursor position?
          >
          >Normally, vim remembers that your cursor was in column 17 (over the
          >'O') when you moved it to the empty line and moves the cursor back
          >to column 17 when you move it again to the next line having 17 or
          >more columns. If, when the cursor is at the first column of that
          >blank line, your plugin executes a command that remembers the cursor
          >position, moves the cursor someplace else, then restores the cursor
          >position, vim thinks the user has deliberately moved the cursor to
          >column 1 and uses that "desired column number" when the user
          >subsequently moves the cursor to the next line. This leaves the
          >cursor in column 1 when you think it should have moved back to
          >column 17.
          >
          >I think this problem can be solved by using the winsaveview()
          >function to save the cursor and view information before moving the
          >cursor, then using the winrestview() function to restore the cursor
          >and view. These functions are new with vim 7.0 and I haven't tried
          >them yet.

          Yes, I use CursorMoved autocommand and winsaveview() to
          save the view information.

          I have tried the plugin on vim with the newest patches and with
          options -u NONE -N, then it looked to be working correctly.
          Maybe some plugin interfered it?

          Anyway thank you for advice, Gary.

          Regards,

          --
          AOYAMA Shotaro
          mailto:jod@...
        Your message has been successfully submitted and would be delivered to recipients shortly.