Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

like image 805
aresnick Avatar asked Mar 01 '12 01:03

aresnick


2 Answers

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.

like image 147
Kevin Avatar answered Oct 06 '22 20:10

Kevin


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.

like image 38
Lorem Ipsum Avatar answered Oct 06 '22 20:10

Lorem Ipsum