如何解决vim sed匹配多个换行符并替换为一个换行符
| 我在使用vim时遇到了麻烦,gg = G不会删除多余的换行符,我正在尝试:%s/\\(\\n\\)\\n\\+/\\1/g
但无法在整个文件中使用。任何帮助表示赞赏。
解决方法
这应该在
vim
中工作...
:g/^\\s*$/d
, \" Put the function bellow in your vimrc
\" remove extra newlines keeping the cursor position and search registers
fun! DelBlank()
let _s=@/
let l = line(\".\")
let c = col(\".\")
:g/^\\n\\{2,}/d
let @/=_s
call cursor(l,c)
endfun
\" the function can be called with \"leader\" d see :h <leader>
map <special> <leader>d :keepjumps call DelBlank()<cr>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。