Search code examples
vimrestructuredtext

Add a number of '=' in a rest (reStructuredText) document that equals to characters from last line?


I want to use a shortcut to add needed = (from Section/Title reStructuredText syntax) according to the last line.

So, suppose (being | the cursor position)

Title
|

and pressing an specific mapping mapped to a function, add a number of = that equals to the last line (where Title is), becoming:

Title
=====|

Solution

  • This sequence will get you close:

    kyyp:.s/./=/g
    

    Duplicate the previous line, then in that line, change every character to an equals sign. Map that to a key sequence you like, and try it out.