5

Recently I discovered emacs as a text editor for my latex documents. So far, I am excited with how powerful the editor is. However, I have a problem with line wrapping.

More precisely, in the option menu I choose line wrapping in this buffer --> word wrap. After that, I choose save options, but when I reopen my tex file, line wrapping is back to the default setting.

So, my question is how can I set word wrap as my default wrapping option for all my documents?

Thanks in advance

8

As you noticed, the menu entry says "Line Wrapping in This Buffer" so this is not something that is saved by "Save Options".

To enable visual-line-mode in all your latex documents, add the following in your init file (~/.emacs or ~/.emacs.d/init.el):

(add-hook 'LaTeX-mode-hook #'visual-line-mode)

This ensures the function visual-line-mode (aka "word wrap") is called for each buffer that is put in LaTeX-mode (assuming you're using AUCTeX).

More information about the hook mechanism can be found in the emacs manual.

10

JeanPierre's answer will work fine if you want to use different word wrapping per type of document.

If you want all your documents word-wrapped, use the following:

(global-visual-line-mode t)

in your ~/.emacs or ~/.emacs.d/init.el file.

You can customize that value via the menus as well, by going to "Options->Customize Emacs->All Settings Matching..." and searching for "visual."

  • This is the right answer--the OP asked how to turn on word wrap for all files. – James Apr 10 '18 at 15:43
  • Out of curiosity, do you know why this isn't the default? What's the benefit of not having line-wrap? To me it's 99% just a nuisance – mowwwalker Jul 28 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.