Is there a clever way to underline a heading?

2

This isn't a particularly important, but it's something I've been curious about for a while.

I write a lot of documentation using rST (Sphinx). This is how you write a heading:

My Awesome Heading
==================

Lorem ipsum dolor...

I'm wondering if there's a clever way in vim to do that underline, rather than just rapidly pressing the equals key a dozen times.

Theron Luhn

Posted 2013-12-23T02:54:17.873

Reputation: 169

Answers

6

" underline current line
yypVr=

broomdodger

Posted 2013-12-23T02:54:17.873

Reputation: 1 810

A bit shorter: the default behavior for Y is the same as yy. – pandubear – 2013-12-28T07:21:21.950

4

:t.|s/./=/g

One keypress shorter than Barton's solution. ;)

n.st

Posted 2013-12-23T02:54:17.873

Reputation: 1 538

thx, this is going to my vimrc. – amdorra – 2013-12-23T04:26:52.307

Shifting is a keypress. You tied. :) – codelahoma – 2013-12-28T21:21:18.510

2

Try

yyp
:s/./=/g

This copies and pastes the current line, then substitutes '=' for each character.

You can wrap this a macro or set up a function within .vimrc

Barton Chittenden

Posted 2013-12-23T02:54:17.873

Reputation: 1 698