Add a semicolon when I hit enter

I write CNC programs on LibreOffice Writer. Is there a way that I can set up the program to automatically add a semicolon every time I hit enter? Preferably this would be able to be turned on and off as I don’t want this feature on when writing a letter or something.