regex - inline multiple matching within a search string in perl -
i have opengl code have special indentation after running astyle. example,
glbegin(gl_lines); glvertex2f(1.0f, 2.0f); glvertex2f(1.0f, 2.0f); glvertex2f(1.0f, 2.0f); glvertex2f(1.0f, 2.0f); glend();
the above code want change thing below.
glbegin(gl_lines); glvertex2f(1.0f, 2.0f); glvertex2f(1.0f, 2.0f); glvertex2f(1.0f, 2.0f); glvertex2f(1.0f, 2.0f); glend();
in special case whatever there in between glbegin , glend want shift 4 white spaces.
i want inline , using perl.
it's hard mean "inline." assume want use -e
command line option. pretty simple use of perl. should spend time documentation. in windows cmd shell:
perl -p -e "$i=0 if/glend/;s/^/ / if $i;$i=1 if /glbegin/" < infile.c > outfile.c
in bash replace double quotes single ones.
Comments
Post a Comment