Raf*_*ian 17
:%s/.\{80}/&\r/g
Run Code Online (Sandbox Code Playgroud)
您还可以修改此批准的答案,仅在第 80 个字符之后出现的第一个空格处插入换行符:
%s/\(.\{80\}.\{-}\s\)/\1\r/g
Run Code Online (Sandbox Code Playgroud)
使用正则表达式:
:%s/\(.\{80\}\)/\1\r/g
Run Code Online (Sandbox Code Playgroud)
使用递归Vim宏:
qqqqq79la<Enter><esc>@qq@q
qqq Clear contents in register q.
qq start marco in register q
79la<Enter> Carriage return after 80 characters.
<esc> go back to normal mode
@q run macro q which we are about to create now.
q complete recording macro
@q run macro
Run Code Online (Sandbox Code Playgroud)