Gregg's MOTD

Tips & Tricks that I've Encountered Over the Years...

Vim: Underlining a Line

September 12, 2023 — Gregg Szumowski

Of course, Vim is just a text editor but you can underline a line using a set of keystrokes that copies the string to be underlined to the next line and then replaces the string with hyphens using this set of Vim commands: YpVr-

So if you have a line:

This Is My Page Title

just position the cursor at the start of that line and enter the abovementioned commands and it will turn it into:

This Is My Page Title
---------------------

This would save you a few keystrokes if you use Vim for creating a lot of text documentation and use hyphens a lot in your section headers.

Tags: cli, vim, motd