2 ms·
The command you want is just gq. In normal mode it accepts a motion, eg gqip or gq}. And it works in visual mode as well. The gqq command is a special case for
by nerdponx 3y ago
The command you want is just gq. In normal mode it accepts a motion, eg gqip or gq}. And it works in visual mode as well. The gqq command is a special case for the current line. Personally I use https://github.com/kana/vim-textobj-line https://github.com/kana/vim-textobj-line which defines a text object for the current line and maps it to _, so gq_ also formats the current line.
See here for relevant documentation: https://neovim.io/doc/user/change.html#formatting https://neovim.io/doc/user/change.html#formatting
- nkouevda 3y agofyi _ is a built-in motion; that plugin defines a couple others: il and al, which are specifically characterwise (vs. _ can be either that or linewise) gq is a linewise operation anyway, so gq_, gqil, and gqal all have the same effect
- nerdponx 3y agoWait really? Is that new? I could have sworn it wasn't back when I first started (Vim 7 era).