Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/indent-object.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ This exceptional behaviour can be disabled by executing the following line
<
(default is 1)

Also, blank line behaviour can be disabled by executing the following lne
>
:let g:indent_object_ignore_blank_line = 0
<
(default is 1)


==============================================================================
ABOUT *indtobj-about*
Expand Down
12 changes: 8 additions & 4 deletions plugin/indent-object.vim
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ if !exists("g:indent_object_except_first_level")
let g:indent_object_except_first_level = 1
endif

if !exists("g:indent_object_ignore_blank_line")
let g:indent_object_ignore_blank_line = 1
endif

function! <Sid>TextObject(inner, incbelow, vis, range, count)

" Record the current state of the visual region.
Expand Down Expand Up @@ -111,9 +115,9 @@ function! <Sid>TextObject(inner, incbelow, vis, range, count)
endif

" Search backward for the first line with less indent than the target
" indent (skipping blank lines).
" indent.
let blnk = getline(l_1) =~ "^\\s*$"
while l_1 > 0 && (blnk || indent(l_1) >= idnt)
while l_1 > 0 && (( g:indent_object_ignore_blank_line && blnk ) || indent(l_1) >= idnt)
if g:indent_object_except_first_level && idnt == 0 && blnk
break
endif
Expand All @@ -125,10 +129,10 @@ function! <Sid>TextObject(inner, incbelow, vis, range, count)
endwhile

" Search forward for the first line with more indent than the target
" indent (skipping blank lines).
" indent.
let line_cnt = line("$")
let blnk = getline(l2) =~ "^\\s*$"
while l2 <= line_cnt && (blnk || indent(l2) >= idnt)
while l2 <= line_cnt && (( g:indent_object_ignore_blank_line && blnk ) || indent(l2) >= idnt)
if g:indent_object_except_first_level && idnt == 0 && blnk
break
endif
Expand Down