如何修复以下文本中的自动换行,以便注释 # 字符也被修复?
鉴于这种:
# This is documentation
# that
# is very helpful. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc sagittis eget dolor sed ultricies.
我想要这个:
# This is documentation that is very
# helpful. Lorem ipsum dolor sit amet,
# consectetur adipiscing elit. Nunc
# sagittis eget dolor sed ultricies.
(使用任意:set tw=42
)
正如 muru 在 comments 中指出的那样,
gq}
如果光标最初位于要重新格式化的文本的第一行并且要重新格式化段落的其余部分(这是移动命令所涵盖的内容),则该命令将执行此}
操作。光标将移动到段落末尾。您也可以用来
gw}
执行相同的操作,但不会因操作而移动光标。该gw
命令也不使用formatprg
orformatexpr
,如果设置了这些,则gq
可以。要重新格式化当前段落,而不必先将光标重新定位在段落开头,请使用
gqap
或gwap
(分别相当于gq}
和gw}
)。