Vim:用字符填充行

2024-04-25

如何在一行或多行末尾重复添加字符,将行填充到特定列?

例如:
(“x”代表第 40 列,不是该行上的字符;并且文本后没有空格或制表符)

line one                               x
line two                               x
line three                             x
line eleventy-billion                  x

becomes

line one ------------------------------x
line two ------------------------------x
line three ----------------------------x
line eleventy-billion -----------------x

的组合\= http://vimdoc.sourceforge.net/htmldoc/change.html#sub-replace-expression, 子匹配() http://vimdoc.sourceforge.net/htmldoc/eval.html#submatch%28%29, and repeat() http://vimdoc.sourceforge.net/htmldoc/eval.html#repeat%28%29:

:%s/\v^.*$/\= submatch(0) . " " . repeat("-", 39 - len(submatch(0)))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Vim:用字符填充行 的相关文章

随机推荐