23 Jan 2017

Aligning Text in Vim

Did you know you can center align text in vim? From a visual selection, run :center. This aligns the text on the assumption that the width of the document is textwidth, or 80 characters by default. You can also manually set the range by running :center N, where N is the total width of the line.

Unsurprisingly vim also has equivalent commands for left and right aligning text - :left and :right respectively. These also take the same format for range and width arguments.

My main use for these commands? Correctly formatting a message-of-the-day file after making some edits. They’re a definite time saver.

Dev SysAdmin Vim
Back to posts