Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

3 Answers 3

up vote 6 down vote accepted
" underline current line
yypVr=
share|improve this answer
    
A bit shorter: the default behavior for Y is the same as yy. –  pandubear Dec 28 '13 at 7:21

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

share|improve this answer
:t.|s/./=/g

One keypress shorter than Barton's solution. ;)

share|improve this answer
    
thx, this is going to my vimrc. –  amdorra Dec 23 '13 at 4:26
    
Shifting is a keypress. You tied. :) –  codelahoma Dec 28 '13 at 21:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.