I've assembled the following command to take a markdown file and add a ==== under each line that starts with a #:

:g/^#/t. | s/./=/g

How exactly does this work? As far as I understand:

  • :g/ start a global command
  • ^#/ where the line starts with a #
  • /t. (not sure what this is or does, had trouble finding it in help)
  • | (also not quite sure exactly how this works, I've seen a few different examples of this)
  • s/./=/g substitute every character (.) with a =

Any clarification/pointers on the above two components of the commands would be great.

  • 2
    See :h :t and :h :bar. Important feature when searching for help is <C-d>. Just enter :h |<C-d>, it will show any help topics that contains the word bar (Vim is automatically replacing | with bar). Less helpful with :h t<C-d> I have to admit :-).
    – Ralf
    May 31, 2020 at 7:07
  • @Ralf -- cool, thanks for that tip. Now clear on the t ==> alias for co[py]. Still working through . and | -- there are lots of references for them in the docs...
    – David542
    May 31, 2020 at 7:17
  • 1
    The :t -> :copy seems to be historical. It's also in original vi. And: :h :.. David, I don't want to annoy you with all the "see help", but the help of Vim is really good and extensive. It is sometimes a little bit difficult to find the right help subject. Another cool feature is :helpgrep to search through the help files.
    – Ralf
    May 31, 2020 at 7:26
  • @Ralf sure, I appreciate you pointing that out. Out of curiosity, why do you do :h :. instead of just :h . (which is what I was doing previously)?
    – David542
    May 31, 2020 at 7:28
  • 2
    @David542 Simply :h . means "give me help about "dot" in Normal mode", i.e. repeat-operator. While :h :. means "say what is "dot" in the command-line?" Just read the main topic <F1> - right after the words "Get specific help" there are several examples, and also the link to :h help-summary which gives full explanation.
    – Matt
    May 31, 2020 at 7:59

1 Answer 1


The command :to is a synonym of :copy that can be abbreviated to :t. So :[range]t. is a short way of saying copy the lines in the range to the current line.

The | is the command separator; it’s a bit like a semicolon in most C-like languages. See :help :bar.

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.