What algorithm does Vim use to break paragraphs into lines for paragraph fill (gq)?
It is a simple greedy algorithm like the one used in Emacs, or something more sophisticated like the one used in TeX?
And most important, where would I look in the source code to confirm the algorithm that is used?
What algorithm does Vim use to break paragraphs into lines for paragraph fill (
Share
As with many vim things, it’s customisable. The default is a greedy algorithm (“A longer [than
textwidth] line will be broken after whitespace to get this width”), but by settingformatexpryou can use vimscript to format your paragraphs, and by settingformatprg(for example, tofmtorpar) you can cede control to an external program.