I am editing restructuredtext files. I often need to put some charactors like "=-`~" in one line, and I want the length of the line match the previous line. How should I do this in vim?
a long long title
=================
Thanks!
Starting in normal mode, you can press O to insert a blank line before the current line, or o to insert one after. O and o ("open") also switch to insert mode so you can start typing. To add 10 empty lines below the cursor in normal mode, type 10o<Esc> or to add them above the cursor type 10O<Esc> .
vim Inserting text Insert text into multiple lines at once Press Ctrl + v to enter into visual block mode. Use ↑ / ↓ / j / k to select multiple lines. Press Shift + i and start typing what you want. After you press Esc , the text will be inserted into all the lines you selected.
If you're already in vi, you can use the goto command. To do this, press Esc , type the line number, and then press Shift-g .
Another that will work:
yypv$r=
How about yyp:s/./=/g
?
You can map that to a key, e.g.
:map <F5> yyp:s/./=/g<CR>
I would use yypver=
to avoid searching & shift button as much as possible. This could of course also be mapped to a key.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With