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

How to use color to search

Expand Messages
  • lucentjames
    Hi, All I am new to vim. Part of my job is to search a lot of key word from very large LOG files. I am sure I can use vim do it but do not know how. What I
    Message 1 of 6 , Mar 11, 2011
    • 0 Attachment
      Hi, All
       
      I am new to vim. Part of my job is to search a lot of key word from very large LOG files. I am sure I can use vim do it but do not know how.
       
      What I need to do is have some list of keyword group (keyword that have special chararters eg / . ? [ ])and use VIM to mark to different color.
       
      I worked for servial hours still can't get it work. Anybody can help?
       
      Thanks
       
       
      James

      --
      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
    • John Beckett
      ... Syntax rules can be used, or highlighting with matchad(). One approach would be to use this tip (it uses matchadd()):
      Message 2 of 6 , Mar 11, 2011
      • 0 Attachment
        lucentjames wrote:
        > What I need to do is have some list of keyword group (keyword
        > that have special chararters eg / . ? [ ])and use VIM to mark
        > to different color.

        Syntax rules can be used, or highlighting with matchad().

        One approach would be to use this tip (it uses matchadd()):
        http://vim.wikia.com/wiki/Highlight_multiple_words

        Use :Hsample to show a sample of the hightlights, which you can
        change by editing the supplied highlights.csv file.

        Assuming you want the same highlights over several sessions, you
        could put commands like these in a file (say my.vim):

        Hi 7 alpha
        Hi 8 beta
        Hi 9 gamma.delta

        In Vim, use this command to source (apply) the commands:

        :so my.vim

        The '.' in 'gamma.delta' matches any character. It's an easy way
        of highlighting 'gamma delta' (with a space).

        Hmmm, looking at the tip I see that I had forgotten about :Hsave
        and :Hrestore which would be another way to save settings.

        John

        --
        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
      • Jeroen Budts
        ... There is also the Mark-script (http://www.vim.org/scripts/script.php?script_id=2666), which let s you add highlights on-the-fly. You can then also jump
        Message 3 of 6 , Mar 11, 2011
        • 0 Attachment
          On 03/12/2011 03:32 AM, John Beckett wrote:
          > lucentjames wrote:
          >> What I need to do is have some list of keyword group (keyword
          >> that have special chararters eg / . ? [ ])and use VIM to mark
          >> to different color.
          >
          > Syntax rules can be used, or highlighting with matchad().
          >
          > One approach would be to use this tip (it uses matchadd()):
          > http://vim.wikia.com/wiki/Highlight_multiple_words
          >
          > Use :Hsample to show a sample of the hightlights, which you can
          > change by editing the supplied highlights.csv file.
          >
          > Assuming you want the same highlights over several sessions, you
          > could put commands like these in a file (say my.vim):
          >
          > Hi 7 alpha
          > Hi 8 beta
          > Hi 9 gamma.delta
          >
          > In Vim, use this command to source (apply) the commands:
          >
          > :so my.vim
          >
          > The '.' in 'gamma.delta' matches any character. It's an easy way
          > of highlighting 'gamma delta' (with a space).
          >
          > Hmmm, looking at the tip I see that I had forgotten about :Hsave
          > and :Hrestore which would be another way to save settings.
          >
          There is also the Mark-script
          (http://www.vim.org/scripts/script.php?script_id=2666), which let's you
          add highlights on-the-fly. You can then also jump from mark to mark
          (with <Leader>* and <Leader>/).

          Jeroen


          --
          website: http://budts.be/ - twitter: @teranex
          ___________________________________
          Registered Linux User #482240 - GetFirefox.com - ubuntu.com

          --
          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
        • Paul
          Alternatively, the SyntaxMotion script: http://www.vim.org/scripts/script.php?script_id=2965 -- . -- You received this message from the vim_use maillist. Do
          Message 4 of 6 , Apr 1, 2011
          • 0 Attachment
            Alternatively, the SyntaxMotion script: http://www.vim.org/scripts/script.php?script_id=2965

            --

            .

            --
            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
          • Ben Fritz
            ... Or this alternate approach, if you prefer. Instead of marking the lines of interest with special colors, why not fold away all lines so that only the lines
            Message 5 of 6 , Apr 1, 2011
            • 0 Attachment
              On Mar 11, 9:49 am, "lucentjames" <lucentja...@...> wrote:
              > Hi, All
              >
              > I am new to vim. Part of my job is to search a lot of key word from very large LOG files. I am sure I can use vim do it but do not know how.
              >
              > What I need to do is have some list of keyword group (keyword that have special chararters eg / . ? [ ])and use VIM to mark to different color.
              >
              > I worked for servial hours still can't get it work. Anybody can help?
              >

              Or this alternate approach, if you prefer. Instead of marking the
              lines of interest with special colors, why not fold away all lines so
              that only the lines of interest are visible?

              http://vim.wikia.com/wiki/Fold_regular_expression

              --
              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
            • David Ohlemacher
              I don t know what your *nix background is, but if you haven t looked at them, check out grep, sed, and/or awk. One reason is that you said file*s* . With
              Message 6 of 6 , Apr 1, 2011
              • 0 Attachment
                I don't know what your *nix background is, but if you haven't looked at them, check out grep, sed, and/or awk.  One reason is that you said "files".   With sed/awk you could process all your files and generate arbitrarily "nice" report(s) of just what you are looking for and do it for entire directories of files all at once.  I love vim, but in this case, I would use vim to review those reports.

                -d

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