i have the following Text in my vim ('|' is my cursor.:

"|--------------[ LatexBox ]-------------

When i press ci[, nothing happens. I would expect that it doesn't matter where exactly in the line my cursor is. at least when a pair of brackets in the line is.

"--------------[| LatexBox ]-------------

Now, when i press ci[ nvim delets the content of the Brackets and puts me in insert mode, as expected.

=> How can i fix that?

PS: I know this question, but in this example i don't have multiple brackets.

EDIT: Btw. that example doesn't work also in a single buffer without any other content (suggested also in 1)


1 Answer 1


What you see is the expected behavior of ci[ (and ci(, and ci{). There is nothing to "fix", here.

But you can use this script to add your desired behavior to Vim:

" Motion for "next/last object". For example, "din(" would go to the next "()" pair
" and delete its contents.

onoremap an :<c-u>call <SID>NextTextObject('a', 'f')<cr>
xnoremap an :<c-u>call <SID>NextTextObject('a', 'f')<cr>
onoremap in :<c-u>call <SID>NextTextObject('i', 'f')<cr>
xnoremap in :<c-u>call <SID>NextTextObject('i', 'f')<cr>

onoremap al :<c-u>call <SID>NextTextObject('a', 'F')<cr>
xnoremap al :<c-u>call <SID>NextTextObject('a', 'F')<cr>
onoremap il :<c-u>call <SID>NextTextObject('i', 'F')<cr>
xnoremap il :<c-u>call <SID>NextTextObject('i', 'F')<cr>

function! s:NextTextObject(motion, dir)
  let c = nr2char(getchar())

  if c ==# "b"
      let c = "("
  elseif c ==# "B"
      let c = "{"
  elseif c ==# "d"
      let c = "["

  exe "normal! ".a:dir.c."v".a:motion.c

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.