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

Delay Match Highlighting

Expand Messages
  • Taylor Venable
    Hello fellow Vimmers, I know you can set the amount of time that a character-pair match is highlighted using the matchtime variable, but I am wondering if
    Message 1 of 5 , Sep 2, 2007
      Hello fellow Vimmers,

      I know you can set the amount of time that a character-pair match is
      highlighted using the "matchtime" variable, but I am wondering if there is a
      way to set a delay that would expire *before* the pair is highlighted. The
      reason I ask is the following use case:

      When using an XML file, I add <:> to matchpairs. But when navigating
      line-by-line in a large series like --

      <.../>
      <.../>
      <.../>

      Etc -- Vim gets laggy because it's continually looking for and highlighting
      the matching angle brackets. So I was wondering if there was a delay
      anywhere that could be set before the search and highlight is actually
      attempted, which would make single-line navigation in this kind of situation
      much faster.

      --
      Taylor Venable
      taylor@...
      http://www.metasyntax.net/

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Tim Chase
      ... While I don t think there s any way to change the timing to something more delayed, there are a couple of options: 1) tweak the synmaxcol option which
      Message 2 of 5 , Sep 2, 2007
        > When using an XML file, I add <:> to matchpairs. But when navigating
        > line-by-line in a large series like --
        >
        > <.../>
        > <.../>
        > <.../>
        >
        > Etc -- Vim gets laggy because it's continually looking for and highlighting
        > the matching angle brackets. So I was wondering if there was a delay
        > anywhere that could be set before the search and highlight is actually
        > attempted, which would make single-line navigation in this kind of situation
        > much faster.


        While I don't think there's any way to change the timing to
        something more delayed, there are a couple of options:

        1) tweak the 'synmaxcol' option which will "avoid a delay in a
        long line with syntax highlighting" as described at the bottom of
        the text for ":help matchparen" (down at the bottom of the
        pi_paren.txt document)

        2) make some fast-access mappings to enable/disable paren
        matching so you can disable it when you need to, and easily
        reenable it...something like

        :nnoremap <f7> :NoMatchParen<cr>
        :nnoremap <f8> :DoMatchParen<cr>

        which gives easy access to toggling them.

        -tim



        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • A.Politz
        ... I think you re mixing something up. We have showmatch and matchtime , which jump back briefly to the coresponding matchpairs character, but only if
        Message 3 of 5 , Sep 3, 2007
          Taylor Venable wrote:

          >Hello fellow Vimmers,
          >
          >I know you can set the amount of time that a character-pair match is
          >highlighted using the "matchtime" variable, but I am wondering if there is a
          >way to set a delay that would expire *before* the pair is highlighted. The
          >reason I ask is the following use case:
          >
          >When using an XML file, I add <:> to matchpairs. But when navigating
          >line-by-line in a large series like --
          >
          > <.../>
          > <.../>
          > <.../>
          >
          >Etc -- Vim gets laggy because it's continually looking for and highlighting
          >the matching angle brackets. So I was wondering if there was a delay
          >anywhere that could be set before the search and highlight is actually
          >attempted, which would make single-line navigation in this kind of situation
          >much faster.
          >
          >
          >
          I think you're mixing something up.
          We have 'showmatch' and 'matchtime', which jump back briefly
          to the coresponding 'matchpairs' character, but only if you insert
          one of this chars.

          A different thing is the matchparen plugin which has nothing
          to do with 'matchtime' and 'showmatch', but what is lagging
          you.

          Instead of switching it on and off, you could also try
          to put the cursor in a column without matchpair-chars while
          scrolling.

          -ap

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • A.Politz
          ... Here is some evil hack , which maybe noone should ever use ... It uses getchar() to peek in the typeahead buffer shuts off Matchparen and defines a
          Message 4 of 5 , Sep 3, 2007
            Taylor Venable wrote:

            >Hello fellow Vimmers,
            >
            >I know you can set the amount of time that a character-pair match is
            >highlighted using the "matchtime" variable, but I am wondering if there is a
            >way to set a delay that would expire *before* the pair is highlighted. The
            >reason I ask is the following use case:
            >
            >When using an XML file, I add <:> to matchpairs. But when navigating
            >line-by-line in a large series like --
            >
            > <.../>
            > <.../>
            > <.../>
            >
            >Etc -- Vim gets laggy because it's continually looking for and highlighting
            >the matching angle brackets. So I was wondering if there was a delay
            >anywhere that could be set before the search and highlight is actually
            >attempted, which would make single-line navigation in this kind of situation
            >much faster.
            >
            >
            >
            Here is some 'evil hack', which maybe noone should ever use
            :).
            It uses getchar() to peek in the typeahead buffer shuts
            off Matchparen and defines a Cursorhold aucommand to
            reenable it again. It also needs a patched matchparen.vim,
            since both matchparen commands contain :windos, which kinda
            throw us out of our window.

            -----------------%<-----------------------------------
            let s:c_line=0
            func! SwitchOffMatchParen()
            if line('.') == s:c_line
            return
            else
            let s:c_line=line('.')
            endif
            "create some lag, adjustable
            sleep 5ms
            if getchar(1)
            :NoMatchParen
            call ToggleAucommands(1)
            endif
            endfun

            func! ToggleAucommands( arg )
            if a:arg
            set updatetime=100
            augroup _mp
            au!
            au CursorHold * :call ToggleAucommands(0) | set updatetime&vim |
            :DoMatchParen
            augroup END
            else
            augroup _mp
            au!
            au CursorMoved * :call SwitchOffMatchParen()
            augroup END
            endif
            endfun

            :DoMatchParen
            call ToggleAucommands(0)
            -----------------%<-----------------------------------


            matchparen.vim---%<-----------------------------------
            "Define commands that will disable and enable the plugin.
            command! NoMatchParen let c_win=winnr() | exe "windo 3match none " |
            exec c_win."wincmd w" | unlet c_win | unlet! g:loaded_matchparen |
            \ au! matchparen
            command! DoMatchParen runtime plugin/matchparen.vim | let c_win=winnr()
            | exec "windo doau CursorMoved" | exec c_win."wincmd w" | unlet c_win
            -----------------%<-----------------------------------



            -ap


            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • A.Politz
            ... This seems to work pretty well : let g:can_do_updates = 10 let g:last_known_cursor_line = 0 au CursorHold,WinEnter * :let g:can_do_updates = 10 | doauto
            Message 5 of 5 , Sep 12, 2007
              Taylor Venable wrote:

              >Hello fellow Vimmers,
              >
              >I know you can set the amount of time that a character-pair match is
              >highlighted using the "matchtime" variable, but I am wondering if there is a
              >way to set a delay that would expire *before* the pair is highlighted. The
              >reason I ask is the following use case:
              >
              >When using an XML file, I add <:> to matchpairs. But when navigating
              >line-by-line in a large series like --
              >
              > <.../>
              > <.../>
              > <.../>
              >
              >Etc -- Vim gets laggy because it's continually looking for and highlighting
              >the matching angle brackets. So I was wondering if there was a delay
              >anywhere that could be set before the search and highlight is actually
              >attempted, which would make single-line navigation in this kind of situation
              >much faster.
              >
              >
              >
              This seems to work pretty well :

              let g:can_do_updates = 10
              let g:last_known_cursor_line = 0
              au CursorHold,WinEnter * :let g:can_do_updates = 10 " | doauto CursorMoved
              au CursorMoved * if line('.') != g:last_known_cursor_line |
              \let g:can_do_updates -= 1|
              \let g:last_known_cursor_line = line('.') |
              \endif


              Copy matchparen.vim to your ~ and change the line where it
              returns if pumvisible() to

              if pumvisible() || g:can_do_updates < 0

              10 is an arbitrary value. After the cursor was moved 10 lines
              up or down, matchparen will pause till the next CursorHold event.
              set updatetime=1000
              or even less if you don't experience problems.
              The doauto would be nice, to switch on matchparen without the
              need of moving the cursor after you stop on a paren,
              but this will also trigger reparsing the modeline (and has maybe
              other sideeffects ).

              -ap

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