VIM: simple steps to create syntax highlight file - for logfiles -


I have to go through some (log4j generated) logfiles; I know their nature very well (I mean, I can already use Pass-Pug Reggaeus etc.).

I want to highlight them automatically in VIM when I load them (* .log).

A logfile entry looks like this:

  YYYY-MM-DD HH: MM: SS, SSS [...] # log-level # [ .] Message ## LOG-LEVEL # Standard 'error', 'INFO', 'DEBUG', 'FATAL' .... and 'YYYY-MM ...' date / Time represents the millisecond resolution.  

To start with me, what are the steps needed to highlight the date string in the yellow strip with blue text - and whenever the text reads 'error', then in white color There should be a red background with

I have tried to go through some tutorials on this, but one can not find that which is quite simple to understand, so I am here after some real basic steps!

Cheers

Edit: Based on the instructions given below, here's a summary of what I did:

  1. Syntax file 'Log.vim' was created IN .vim \ syntax (see below for example content).

  2. A file was created in .vim \ ftdetect \ log.vim with the following content:

    AU BufRead, BufNewFile * .log set file type = Log

  3. Make sure that my startup settings have the following:

    syntax on file type>

    There are three ways to define syntax items (see : help: Syn-define ):

    • Keywords: These items are for the simple st of the keyword characters The ring is I. It is the fastest mile.
    • Mail: There are regular expressions for these matches.
    • Areas: These are for long areas which have the possibility of other items.

    There are many arguments that make things even more complex (with the match within the field), see : help: syn-arguments on this For discussion.

    is a priority that comes in effect (see : support: sync prioritization ).

    The color is controlled by the highlight command and the syntax is different from the command.

    An easy way to get started is to use a match to find dates and keywords to detect the error. Then use the highlight in the colors to come in life:

      "This creates a keyword error and puts it in the highlight group that logarre: syn keyword log error error" Creates matches and puts them in Highlights group called "Next Group and Squiwite seeks Wim for log time after match: Sync Mail LogDate / ^ \ d \ {4} - \ d \ {2} - \ d \ {2} / nextgroup = logTime skipwhite "It creates a match time (but only Ga occurs after the date): syn match matchtime / \ d \ {2}: \ d \ {2}: \ d \ {2}, \ d \ {3} / "now reveal them:" the link just Login to the link "Error to fill the error for the error Hi Link Log Error Error" Def means the default color - can override the colors hi def logDate guibg = yellow guifg = blue hi def logTime guibg = green guifg = White  

    all in / .vim / syntax / log.vim and ensure that the file type is set correctly (see : help filetype.txt ) - e Sector should automatically load.

    Hopefully you should walk with something. Read the various sections (very slowly) of : help syntax.txt and : help usr_44.txt for more information.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -