Using VI to create text headers

Is there a way to easily create a text title in VI? I would like to create a heading like the one below without having to count the characters in order to center.

# ********** a centered title **********

Any vi voodoo you need to have? The best method?

+3
source share
2 answers

You can center the current line using: center (in vim). Then use "R" to fill in the stars after the fact. Still not fast or magical, but at least it saves you from counting characters.

So the steps are:

  • Enter the title
  • : Centre
  • '0' back to the beginning of the line
  • "R" overwrite mode, put asterisks over spaces.

"set expandtab", tabstops, , .

+7

.exrc vi:

map £ A ^[80A£§^[080lD:s/§//g^M$byw0Pa ^[080lD:s/£/*/g^M0R# ^[^M

(Typing ^[ CTRL-V, ESC. ^M CTRL-V, ENTER)

:

  • (£§, , ) 80 ( 160 )
  • 80
  • (§ £ )

, , , £. , , @, : map @ ...

+2

Source: https://habr.com/ru/post/1713241/


All Articles