aresnick
aresnick

Reputation: 1635

What is the equivalent of emacs's fill-paragraph in MacVim?

I'm familiar with solutions that will automatically wrap to 80 characters, etc. But fill-paragraph lets me wrap things to 80 characters (or whatever) when I want to, which is convenient.

Upvotes: 22

Views: 4674

Answers (2)

Lorem Ipsum
Lorem Ipsum

Reputation: 4534

If you care about your cursor staying put, then use gwip.

The gw command has the form gw{motion}. The gw command formats the lines that {motion} moves over and puts the cursor back at the same position in the text. The motion ip stands for 'inner paragraph'. You can think of the command as saying "format the paragraph I am in".

To define the fill width to 80 characters, you would want to do either

:set textwidth=80

or

:set tw=80

The textwidth variable defines the maximum width of text that is being inserted. Lines longer than this width are broken after the white space. Note that textwidth is not available in vi.

Note, it's likely that Vim and Emacs have different definitions for what constitutes a paragraph. If you care about that level of detail, you can always read more about the various commands using :help gw, :help ip, :help tw, etc.

Upvotes: 1

Kevin
Kevin

Reputation: 56089

I'm not familiar with emacs or its fill-paragraph, but it sounds like you're looking for gq. It takes a movement, so either highlight what you want to wrap or use a movement command. E.g. gggqG will wrap the entire buffer.

Upvotes: 29

Related Questions