when the word while It acts as a conjunction, it is written without commas, because it should not be separated from the verb it introduces. It must also convey simultaneity between two actions of the period. Examples: “Your students take notes while you explain this grammar rule.” «Carlos Emiliano imagined a rainbow (also rainbow) when putting on the scarf. Realize that the actions of “taking notes” and “explaining” happen simultaneously; likewise that of “to catch a glimpse” and “to put on the shawl”.

When used as an adverb of time and with the meaning equivalent to ‘meanwhile’, it is isolated from the rest of the statement with a comma (or two). Example: «The causes of the disaster have not yet been determined. Meanwhile, the high temperatures sparked other wildfires.

The conjunctive locution while it is applied with the meaning of “instead” and with the same effect of simultaneity. Example: «In Ecuador, spelling is used unclearly Bean, beans And Beanwhile in Spain the words Bean And Bean».

TO REMEMBER: While indicates that two actions or circumstances coincide in time. It goes without a comma if it coordinates simultaneous actions in the same sentence. You need a comma or two when conveying the idea of ​​simultaneity between independent facts or actions. (Updated from language angle from 16-06-2019).

SOURCES:

Spanish dictionary (electronic version), Pan-Spanish dictionary of doubts (2005), New grammar of the Spanish language (2009), of the Royal Spanish Academy and the Association of Spanish Language Academies.