loading...
Cover image for node.js: Text Positioning 101

node.js: Text Positioning 101

skiilaa profile image skiilaa ・1 min read

Yesterday, we covered text coloring, but today is more interesting. We are positioning text.

The way to do it is another magic string. This time it is this:

console.log("\x1b[10;15H%s", "Hello World!");

This would print "Hello World!" on the screen's 10th row, starting at the 15th column.

See, the formula is basically this:

\x1b[r;cH

You just need to change "r" to the specified row and "c" to the specified column, and boom! You just positioned text.

Discussion

markdown guide