This mode does automatic refilling, all the time.
Basically, it hits
M-q automatically after changes to the buffer that might normally trigger auto-filling. This prevents you from ever writing anything other than perfectly filled paragraphs in your buffers. If you need to write a table or anything else non-filled, you need to disable Refill mode temporarily.
M-x refill-mode to toggle it.
Refill mode is often used in conjunction with LongLines. Sometimes you don’t want to refill certain paragraphs. While you edit these, make sure you disable refill mode! Something like the following might be useful. Change the key binding to your taste.
(global-set-key (kbd "C-c q") 'refill-mode)
Like any good word processor, you can change the justification of your paragraphs with the following commands:
M-x set-justification-full – Fully justify the paragraphs
M-x set-justification-left – Left justify the paragraphs
M-x set-justification-center – Center the paragraphs
M-x set-justification-right – Right justify the paragraphs
M-x set-justification-none – Don’t justify the paragraphs
You can either run these commands on a region and perform that action for the region (Hint: C-x h marks the entire buffer as a region), or you can set justification and start typing. Emacs tries to be smart – i.e. if you set-justification-full on a paragraph it’ll be justified full and any paragraphs you type after it will be justified full, but it can be tempermental.
Refill-mode has lots of quirky out of the box behaviour that you can customize to you liking. This section will only cover some of the topics. More information can be found in the emacs manual “Adaptive Fill.”
Refill-mode assumes the user follows the American typist’s convention of adding 2 spaces between each sentences. If you do not include 2 spaces between each sentence, them refill-mode won’t be able to tell between sentence endings and abbreviations. If you want refill-mode to work properly, then use 2 spaces between each sentence. Also, emacs assumes that paragraphs are separated by a blank line. In order for refill-mode to work as expected insert a blank line between paragraphs like this:
This is paragraph 1. This is still paragraph 1. You guessed it; we’re still in paragraph 1.
Wow, we made it to paragraph 2. Yup. This is still paragraph 2.
Ok, this is paragraph 3, and I promise it’ll be the last paragraph in this trivial example.