Vim delete blank lines

后端 未结 14 2466
情歌与酒
情歌与酒 2020-12-02 03:33

What command can I run to remove blank lines in Vim?

相关标签:
14条回答
  • 2020-12-02 04:05

    This function only remove two or more blank lines, put the lines below in your vimrc, then use \d to call function

    fun! DelBlank()
       let _s=@/
       let l = line(".")
       let c = col(".")
       :g/^\n\{2,}/d
       let @/=_s
       call cursor(l, c)
    endfun
    map <special> <leader>d :keepjumps call DelBlank()<cr>
    
    0 讨论(0)
  • 2020-12-02 04:06
    :v/./d
    

    or

    :g/^$/d
    

    or

    :%!cat -s
    
    0 讨论(0)
提交回复
热议问题