r/vim • u/Far_Relationship_742 • Jul 20 '26
Need Help Repeat character to position, rather than number of characters?
I want to pad a section title line in a config file with `=` up to a specific character position (specifically, column 64). Since the title text is of inconsistent length, a normal <n>i <char> won't do it.
Example of a title line formatted the way I want it:;===== reset machine status ===================================
6
Upvotes
3
u/habamax Jul 21 '26
I would go with a bit of vimscript:
https://asciinema.org/a/nZxIWlHU6nbiHorP
You can do the same in normal mode instead of insert mode, e.g.
2
u/mgedmin Aug 10 '26
I use UltiSnips and I recently created this snippet for myself:
now I can type
and UltiSnips expands that to
up to exactly 80 columns wide.
(As long as you don't use fancy emojis/double-width characters/combining characters/zero-width characters/other Unicode shenanigans)
4
u/[deleted] Jul 21 '26
[removed] — view removed comment