guillermooo
guillermooo

Reputation: 8115

How to apply new textwidth to whole buffer in Vim

I've changed the textwidth option mid-way through my file and I'd like to reformat the whole buffer to use the new width. What's the quickest way to do this?


Solution - Vim documentation topic

gq

Upvotes: 16

Views: 6461

Answers (2)

Alan Haggai Alavi
Alan Haggai Alavi

Reputation: 74202

gq<motion>

For example, if your file consists of 100 lines, move to the first line and then press:

gq100<Down Arrow>

You can use the visual mode to select the lines and then press gq as well.

Upvotes: 10

Rook
Rook

Reputation: 62528

See

:help gq

if it helps.

Upvotes: 17

Related Questions