当您使用{和}中的vim中的段落导航时,它会跳过只包含空格的行,尽管它们否则为空白。
@H_301_4@我如何说服vim将“仅空白”线视为段落,所以{和}会跳到他们?
我如何说服vim将“仅空白”线视为段落,所以{和}会跳到他们?
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 <silent> } :<C-U>call ParagraphMove( 1,v:count)<CR> onoremap <silent> } :<C-U>call ParagraphMove( 1,v:count)<CR> " vnoremap <silent> } :<C-U>call ParagraphMove( 1,1)<CR> nnoremap <silent> { :<C-U>call ParagraphMove(-1,v:count)<CR> onoremap <silent> { :<C-U>call ParagraphMove(-1,v:count)<CR> " vnoremap <silent> { :<C-U>call ParagraphMove(-1,1)<CR>