i[ "inner [] block", select [count] '[' ']' blocks. This
goes backwards to the [count] unclosed '[', and finds
the matching ']'. The enclosed text is selected,
- excluding the '[' and ']'. The |cpo-M| option flag
+ excluding the '[' and ']'. It's an error to select an
+ empty inner block like "[]". The |cpo-M| option flag
is used to handle escaped brackets.
When used in Visual mode it is made characterwise.
ib "inner block", select [count] blocks, from "[count] [("
to the matching ')', excluding the '(' and ')' (see
|[(|). If the cursor is not inside a () block, then
- find the next "(". The |cpo-M| option flag
+ find the next "(". It's an error to select an empty
+ inner block like "()". The |cpo-M| option flag
is used to handle escaped parenthesis.
When used in Visual mode it is made characterwise.
i> *v_i>* *v_i<* *i>* *i<*
i< "inner <> block", select [count] <> blocks, from
the [count]'th unmatched '<' backwards to the matching
- '>', excluding the '<' and '>'. The |cpo-M| option flag
- is used to handle escaped '<' and '>'.
+ '>', excluding the '<' and '>'. It's an error to
+ select an empty inner block like "<>". The |cpo-M|
+ option flag is used to handle escaped '<' and '>'.
When used in Visual mode it is made characterwise.
*v_at* *at*
i{ *v_iB* *v_i{* *iB*
iB "inner Block", select [count] Blocks, from "[count] [{"
to the matching '}', excluding the '{' and '}' (see
- |[{|). The |cpo-M| option flag is used to handle
+ |[{|). It's an error to select an empty inner block
+ like "{}". The |cpo-M| option flag is used to handle
escaped braces.
When used in Visual mode it is made characterwise.
call assert_beeps("normal Vipip")
exe "normal \<C-C>"
- close!
+ bw!
endfunc
" Tests for text object aw
normal $hhyi"
call assert_equal('bar', @")
- close!
+ bw!
endfunc
" Test for i(, i<, etc. when cursor is in front of a block
normal 0di)
call assert_equal('foo ()', getline(1))
- close!
+ bw!
+endfunc
+
+func Test_inner_block_empty_paren()
+ new
+ call setline(1, ["(text)()", "", "(text)(", ")", "", "()()"])
+
+ " Example 1
+ call cursor(1, 1)
+ let @" = ''
+ call assert_beeps(':call feedkeys("0f(viby","xt")')
+ call assert_equal(7, getpos('.')[2])
+ call assert_equal('(', @")
+
+ " Example 2
+ call cursor(3, 1)
+ let @" = ''
+ call assert_beeps('call feedkeys("0f(viby", "xt")')
+ call assert_equal(7, getpos('.')[2])
+ call assert_equal('(', @")
+
+ " Example 3
+ call cursor(6, 1)
+ let @" = ''
+ call assert_beeps('call feedkeys("0f(viby", "xt")')
+ call assert_equal(3, getpos('.')[2])
+ call assert_equal('(', @")
+ bwipe!
+endfunc
+
+func Test_inner_block_empty_bracket()
+ new
+ call setline(1, ["[text][]", "", "[text][", "]", "", "[][]"])
+
+ " Example 1
+ call cursor(1, 1)
+ let @" = ''
+ call assert_beeps(':call feedkeys("0f[viby","xt")')
+ call assert_equal(7, getpos('.')[2])
+ call assert_equal('[', @")
+
+ " Example 2
+ call cursor(3, 1)
+ let @" = ''
+ call assert_beeps('call feedkeys("0f[viby", "xt")')
+ call assert_equal(7, getpos('.')[2])
+ call assert_equal('[', @")
+
+ " Example 3
+ call cursor(6, 1)
+ let @" = ''
+ call assert_beeps('call feedkeys("0f[viby", "xt")')
+ call assert_equal(3, getpos('.')[2])
+ call assert_equal('[', @")
+ bwipe!
+endfunc
+
+func Test_inner_block_empty_brace()
+ new
+ call setline(1, ["{text}{}", "", "{text}{", "}", "", "{}{}"])
+
+ " Example 1
+ call cursor(1, 1)
+ let @" = ''
+ call assert_beeps(':call feedkeys("0f{viby","xt")')
+ call assert_equal(7, getpos('.')[2])
+ call assert_equal('{', @")
+
+ " Example 2
+ call cursor(3, 1)
+ let @" = ''
+ call assert_beeps('call feedkeys("0f{viby", "xt")')
+ call assert_equal(7, getpos('.')[2])
+ call assert_equal('{', @")
+
+ " Example 3
+ call cursor(6, 1)
+ let @" = ''
+ call assert_beeps('call feedkeys("0f{viby", "xt")')
+ call assert_equal(3, getpos('.')[2])
+ call assert_equal('{', @")
+ bwipe!
+endfunc
+
+func Test_inner_block_empty_lessthan()
+ new
+ call setline(1, ["<text><>", "", "<text><", ">", "", "<><>"])
+
+ " Example 1
+ call cursor(1, 1)
+ let @" = ''
+ call assert_beeps(':call feedkeys("0f<viby","xt")')
+ call assert_equal(7, getpos('.')[2])
+ call assert_equal('<', @")
+
+ " Example 2
+ call cursor(3, 1)
+ let @" = ''
+ call assert_beeps('call feedkeys("0f<viby", "xt")')
+ call assert_equal(7, getpos('.')[2])
+ call assert_equal('<', @")
+
+ " Example 3
+ call cursor(6, 1)
+ let @" = ''
+ call assert_beeps('call feedkeys("0f<viby", "xt")')
+ call assert_equal(3, getpos('.')[2])
+ call assert_equal('<', @")
+ bwipe!
endfunc
" vim: shiftwidth=2 sts=2 expandtab