2

Is there a good reason why gJip doesn't turn a paragraph into a line?

If not, how could I make it work that way?

5
  • 3
    because gJ is not an operator, that waits for a motion afterwards. You can however use vipgJ to join all lines in the current paragraph. Oct 26 '19 at 13:44
  • @ChristianBrabandt, vipJ worked as well.
    – Toothrot
    Oct 26 '19 at 13:46
  • @ChristianBrabandt, I meant reason as distinct from cause.
    – Toothrot
    Oct 26 '19 at 13:48
  • 2
    Well, vipJ does something (slightly) different than vipgJ Oct 27 '19 at 10:06
  • @ChristianBrabandt, care to elaborate on the difference?
    – Toothrot
    Oct 27 '19 at 12:08
4

The answer is simple: gJip doesn't work, because gJ is not an operator. See :h operator for which operators exist. The easy workaround is to use visual mode, and then join all the lines, e.g. use vipgJ, because in visual mode gJ will join all those selected lines (see :h v_gJ).

If you want to know the reason, why gJ and also J has not been implemented as an operator, you have to ask Bill Joy (for J in original vi) and Bram Moolenaar (for gJ only available in Vim). My guess is, that using e.g. a motion for the join operation does not always make sense, e.g. the command Jw is non-sense.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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