Vim 用字符填充行

Vim 用字符填充行,vim,Vim,如何在一行或多行末尾重复添加字符,将行填充到特定列 例如: ('x'表示第40列,而不是行中的字符;文本后没有空格或制表符) 变成 line one ------------------------------x line two ------------------------------x line three ----------------------------x line eleventy-billion -----------------x 和的组合: 为了防止将来有人偶然发现这

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

例如:
('x'表示第40列,而不是行中的字符;文本后没有空格或制表符)

变成

line one ------------------------------x
line two ------------------------------x
line three ----------------------------x
line eleventy-billion -----------------x
和的组合:


为了防止将来有人偶然发现这一点,我有另一种方法可以使用 这(我认为)在极少数情况下更容易记住,需要手动填充一些行

输入文本:

Here are some words
They do not have equal length
I want to insert characters after them until column 40
How to do?
您键入的内容:

gg                // Position cursor anywhere on first line you want to pad
q1$40A-<Esc>d40|q // Looks more complex than it is.
                  // Here, in English:
                  // 1. Record a macro in slot 1
                  // 2. Go to the end of the line, then *A*ppend a '-' 40 times
                  // 3. Delete from cursor position (which is still at the end of the line) to column 40
                  // 4. Stop recording
:1,4normal @1     // Repeat macro "1" for every line
希望您能够找出如何调整命令的各个部分,使其完全符合您的要求注意
超过所需列跨度的文本将被截断(如第3行所示)。

O\O。不完全是我希望的三击键解决方案;)我基本上了解您在这里所做的事情,但是\v在开始时做什么?此外,为什么运行该替换会影响语法着色?\v在正则表达式的开头会使所有标点符号变得特别;我这样做是出于习惯,所以我不必记住什么是特别的,什么不是。除非额外的破折号是无效的语法,否则它不应该突出显示语法?尝试ctrl-L重新绘制屏幕。啊。感谢您提供有关\v的信息。而且它是有效的语法(至少破折号在注释掉的行中)。而重画也无济于事。但奇怪的是,搜索恢复了它。Vim语法着色对我来说是一门黑色艺术哦,我明白了。执行搜索或替换后,Vim(启用hlsearch)将突出显示匹配的所有内容,以及我的正则表达式匹配项。。所有内容,因此整个文档都会高亮显示,模糊语法颜色。使用:noh关闭上次搜索的突出显示。是的,搜索突出显示适用于整个文档,而不管:s上的范围是什么。这是一个非常有用和有创意的答案,甚至还成功地将宏输入!
Here are some words
They do not have equal length
I want to insert characters after them until column 40
How to do?
gg                // Position cursor anywhere on first line you want to pad
q1$40A-<Esc>d40|q // Looks more complex than it is.
                  // Here, in English:
                  // 1. Record a macro in slot 1
                  // 2. Go to the end of the line, then *A*ppend a '-' 40 times
                  // 3. Delete from cursor position (which is still at the end of the line) to column 40
                  // 4. Stop recording
:1,4normal @1     // Repeat macro "1" for every line
Here are some words-----------------
They do not have equal length-------
I want to insert characters after t-
How to do?--------------------------