Grammar file (grammar.txt)

361 views Asked by At

I am actually working on a grammar file and I am reading the grammar.txt file.

The 20 first lines are new to me.

%s/^\d*\.\s*(\w*)
%s/^\d*\.\s*\(\w*\)
%s/^\d*\.\s*\(\w*\)/<\1>
%s/^\d*\.\s*\(\w*\)/\1
%s/\<\(\w*\)\>
%s/"\w*\" 
%s/"\(\w*\)\"/_\1_/g
%s/"\(\w*\)\"/&\1&/g
%s/"\(\w*\)\"/123456\1/g
%s/"\(\w*\)\"/**\1**/g
%s/"\(.*\)\"/$\1$/g
%s/"\(\w*\)\"/$\1$/g
%s/"/'/g
%s/'\(\w*\)'\/$\1$/g

Does anyone know what this lines refers to?

1

There are 1 answers

0
Peter Uhnak On

This looks like list of replacement rules someone tried to run in vim. It seems as the someone didn't know how to use it, so was trying to figure it out.

the proper structure is %s/match/replacement/flags

  • %s means search through all lines in the entire file,
  • match is regular expression that you are looking for,
  • replacement is what the match will be replaced with,
  • flags are regexp flags, in this case g, which will replace all occurrences at each line.

more info on vim's search and replace