Is there a way to make it so that

This is a header

converts into

This is a header

in all files who filetype is markdown?

2 Answers 2


Likely it can be done with =TAB, but another approach is:

  1. type your header, then ESCVyESC (copy the whole line in Visual mode)
  2. paste
  3. jVr= (move down, select whole line, replace it with =.

Then You can create a macro or an imap or nmap for it.

Another approach is (after typing your header and getting back to normal mode is: :t.|s/./=/g (ex mode copy line bellow and replace every character on it with =.

  • 1
    yy is enough to copy the line Jun 14, 2017 at 16:47
  • Is there away to somehow attach :t.|s/./=/g or your other method to the =<tab> action? Jun 16, 2017 at 0:26

You could do it this way:

This is a header

On the line with = type:

  1. V puts vim into visual mode.
  2. l (letter l) moves the cursor to the left.
  3. y copies the =.
  4. 5 is the number of =s you want.
  5. p inserts the =s.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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