Support `gw`
Describe the solution you'd like
I need gw{motion} to work in order to edit plain text, like markdown.
Describe alternatives you've considered
There are probably other vim commands that can be used, but gw is what I know.
Oh, gw is like fill-paragraph in emacs, it will wrap long lines based on textwidth.
Does gq do what you need?
Yes it seems like gq does the same thing(?)
On Wed, Jan 29, 2020 at 3:57 PM Maximilian Roos [email protected] wrote:
Does gq do what you need?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/VSCodeVim/Vim/issues/4523?email_source=notifications&email_token=AACS3KIPAXWKYRUOJJUVIMTRAGKMTA5CNFSM4KNAU42KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKHPEDY#issuecomment-579793423, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACS3KPED3WL334NXNGNF6LRAGKMTANCNFSM4KNAU42A .
http://vimdoc.sourceforge.net/htmldoc/change.html#gw
Isn't the current action of gq actually more similar to the gw than the gq though? Except for the cursor position. Because gq is supposed to take into account the 'formatexpr' and 'formatprg' while gw isn't and in our case we don't have any of that, so if we changed the cursor situation this would be more like the gw.
Or are we aiming to just get a gw that is equal to our gq but keeping the cursor? I don't know enough about this commands to know if the 'formatexpr' and 'formatprg' is even feasible to implement in VSCodeVim, maybe it's not.
I agree that the current behavior of gq is a bit jarring to Vim users. As @berknam said, it behaves much more like gw (minus the cursor position).
In vim, I set formatprg to the appropriate formatting tool based on filetype.
autocmd FileType json setlocal formatprg="prettier --parser=json --stdin-filepath --"
Which allows me to gq{motion} (e.g. gggqG to go to top of file and format until end of file). This also works for Go, Terraform, SQL ...etc. See my dotfiles for reference.
I would be fine if gq worked in VS Code by essentially calling Format Document or Format Selection under the hood.
What's the difference between =/equalprg and gq/formatprg in terms of intention?
Per the equalprg and formatprg docs, the way I understand the difference to be is = is only concerned with indentation, while gq handles text formatting in general.
Hmm so maybe we do the following?
- Change
gqto do what=currently does (Format Selection) - Change
=to doReindent Lines - Implement
gwto do whatgqcurrently does (reflow lines), but with correct cursor positioning
Then add equalprg and/or formatprg if someone complains for some reason.
Change gq to do what = currently does (Format Selection)
That would be appreciated!