Make { and } ignore lines containing only whitespace

前端 未结 5 1694
一生所求
一生所求 2021-02-05 09:07

When you navigate by paragraph in vim using { and } it skips lines that contain nothing but whitespace though they are otherwise \'blank\'.

How can I convince vim to tre

5条回答
  •  说谎
    说谎 (楼主)
    2021-02-05 09:46

    I never have a legitimate need for whitespace only lines so I solved this "problem" by adding the following to my .vimrc:

    " Highlight spaces at the end of lines.
    highlight link localWhitespaceError Error
    au Syntax * syn match localWhitespaceError /\(\zs\%#\|\s\)\+$/ display
    
    " Remove end of line white space.
    noremap r ma:%s/\s\+$//e`a
    

    So then if { and } skips whitespace only lines I use my mapping to remove it and try again.

提交回复
热议问题