0

Vim and neovim apparently have two different keys for motions and selections for the text object "paragraph". I find that a bit confusing, can anyone explain what the rationale is?

E.g. I use } to jump to the next paragraph, but I cannot use vi} to select the paragraph I'm currently in, I have to use vip instead. I cannot use p to jump to the next paragraph, though.

In contrast for the object "word" i can use w as a motion and viw as a selection.

Bastian Venthur
  • 12,515
  • 5
  • 44
  • 78

2 Answers2

2

Text objects are special motions that don't map 1:1 with regular motions. They are not meant to be the "selection" variants of regular motions, they are a supplemental set of motions with little to no relationship with the base set.

You mention w and viw, along with an imaginary "word object" but there is no such thing. You have the motion w, which moves the cursor on the first character of the next word, and the text object iw (for "inner word") which has nothing to do with "the next word" at all. The w in the text object iw is not the w in the motion w. In fact, and that's a common misconception, there is no i or w in iw: iw is not two discrete things put together, it is one atomic thing of its own.

Similarly, } and i} are not related in any way and you can't use > to move the cursor to the next HTML tag or s to reach the next sentence. There is, simply put, no connection to expect between regular motions and text objects.

romainl
  • 186,200
  • 21
  • 280
  • 313
0

Keys are limited. So maybe it's simply because p fits "Put the text..." more than "paragraph motion".

leaf
  • 1,624
  • 11
  • 16