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
Here's a modified version that handles counts correctly:
function! ParagraphMove(delta, visual, count)
normal m'
normal |
if a:visual
normal gv
endif
if a:count == 0
let limit = 1
else
let limit = a:count
endif
let i = 0
while i < limit
if a:delta > 0
" first whitespace-only line following a non-whitespace character
let pos1 = search("\\S", "W")
let pos2 = search("^\\s*$", "W")
if pos1 == 0 || pos2 == 0
let pos = search("\\%$", "W")
endif
elseif a:delta < 0
" first whitespace-only line preceding a non-whitespace character
let pos1 = search("\\S", "bW")
let pos2 = search("^\\s*$", "bW")
if pos1 == 0 || pos2 == 0
let pos = search("\\%^", "bW")
endif
endif
let i += 1
endwhile
normal |
endfunction
nnoremap } :call ParagraphMove( 1, 0, v:count)
onoremap } :call ParagraphMove( 1, 0, v:count)
" vnoremap } :call ParagraphMove( 1, 1)
nnoremap { :call ParagraphMove(-1, 0, v:count)
onoremap { :call ParagraphMove(-1, 0, v:count)
" vnoremap { :call ParagraphMove(-1, 1)