Several things, and a lot of playtesting.
--All of my scripts are edited in textpad, and a lot of the older ones are manually formatted for line lengths and (in the cases of Ys 4 and Cyber Knight) window sizes. Textpad contains both column and row cursor indicators, and lets you know how many bytes you've selected.
--Several years back one of the folks who hang out in my IRC channel wrote a line length tester application. You fed it a width table, specified control codes and max line length and the like, and it spat out a results file telling you which lines were overrunning.
These both require a lot of playtesting to make sure that there aren't any overruns, as there's a lot of room for human error in the first and even the second doesn't always catch everything.
All that said, several of my recent projects automatically format their lines as part of an asm hack to their text engines. They detect whether a word will fit on the current line, and if it doesn't, they replace the space before the word with a line break or section break as necessary. This can be tricky to pull off (the first game I wrote it for has a recursive text engine which doesn't even start displaying text until a few recursions in; keeping track of cursor position across recursion depth complicates things immensely) but it eliminates a lot of nastiness if you can pull it off. SRW2, JoJo's Bizarre Adventure, and Ancient Magic all feature this. It's been implemented in one of my unannounced projects and SRW EX as well, which unlike the others are both variable-width. I want to add it to SMT if... and Ladystalker as well, but their text engines are quite a bit more complicated than SRW2 and JJBA.