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.

3 Answers 3

6
" underline current line
yypVr=
1
  • A bit shorter: the default behavior for Y is the same as yy.
    – Pandu
    Dec 28, 2013 at 7:21
4
:t.|s/./=/g

One keypress shorter than Barton's solution. ;)

2
  • thx, this is going to my vimrc.
    – amdorra
    Dec 23, 2013 at 4:26
  • Shifting is a keypress. You tied. :)
    – codelahoma
    Dec 28, 2013 at 21:21
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .