I'm not really sure what you mean. The g-code viewer do not color different layers. The colors come from extruder, feature, speed, width or height. Also when you check 2d view and switch to g-code you see the code of exactly that layer.
I assume you are talking about repetier-server view g-code editor. Not sure since you posted in firmware section.