18

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..." ...


18

Emacs uses visual-line-mode for the soft-wrap and auto-fill-mode (and/or refill-mode) for the hard-wrap. See What is the difference between refill-mode and auto-fill-mode? for the difference between the two.


11

Org-mode files get exported to PDF with the document preparation system LaTeX. Code blocks by default get exported into verbatim environment which does not have line wrapping. You can see this by visiting the .tex file created in the same folder when you export; your code blocks should look like this: \begin{verbatim} import socket # etc \end{verbatim} ...


9

I stumbled across an answer to this... on StackOverflow... You can use the package Adaptive-Wrap. It's pretty nice, there's an "extra indent" option you can use for the wrapped line, though no max indent (but seems like it could be added with just a line or two of code). The author of the Stack Overflow post, Francesco, gives us the basic commands, and ...


9

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")...


7

You can switch on visual-line-mode in org-mode and text-mode by (add-hook 'text-mode-hook #'visual-line-mode) in your init-file (e.g. ~/.emacs). (Thanks to user lawlist for clarifying that org-mode bases on text-mode.) In emacs -Q the command visual-line-mode also sets line-move-visual buffer-locally to t therefore point movement should already work on ...


6

For occasional use, you can do with query-replace-regexp (C-M-%). Replace .\{32\} with \&^J. This means, replace all chunks of 32 characters, with the same thing followed by a newline. To type the newline into the replacemnt, use C-q C-j. If you want to apply this only to binary strings, use [01]\{32\} for matching. This will protect other text from ...


5

(defun my-truncate-lines-disable () "Disable line truncation, even in split windows." (let ((inhibit-message t) ; No messages in the echo area - needs emacs 25+ message-log-max ; No messages in the *Messages* buffer truncate-partial-width-windows) ; No truncation in split windows (toggle-truncate-lines 0))) (add-hook 'help-mode-hook #'...


4

word-wrap is pretty special variable as it's a variable that controls how Emacs' display engine operates when showing a buffer in a window. It is accompanied by wrap-prefix which allows you to prepend space to a wrapped line for the entire buffer: (setq word-wrap t) (setq wrap-prefix (make-string 30 ?\s)) There is no convenient setting for the behaviour ...


3

The short answer (not so good) for turning off truncate-line is: (add-hook 'org-mode-hook #'spacemacs/toggle-truncate-lines-off) But if what you want is line wrap in org mode. This is not a good solution because: truncate-line starts the new line at the beginning of the window, but not the beginning of the previous line. It also adds small arrows on both ...


3

The automatic wrapping is done by the minor mode auto-fill-mode (as hinted by DoMiNeLa10). To disable it, add this to function dotspacemacs/user-config in .spacemacs: (add-hook 'latex-mode-hook #'spacemacs/toggle-auto-fill-mode-off) There is also the latex/auto-fill-mode, but that doesn't seem to be a mode itself (doc: "Toggle auto-fill-mode using the ...


3

You need to add (package-initialize t) at the beginning of your ~/emacs. IIRC Emacs-25 will tend to do that for you, but it's even better to do it manually. The problem is simply that adaptive-wrap-mode is not defined until the ELPA packages have been initialized. If your ~/.emacs file doesn't initialize the ELPA packages with package-initialize, Emacs ...


3

You can customize fill-column or do (setq-default fill-column 80) in your init file and use auto-fill-mode. You can activate it per mode by using (add-hook 'text-mode-hook 'turn-on-auto-fill) or with key binding: (global-set-key (kbd "C-c q") 'auto-fill-mode). See emacswiki for more.


3

Looking at the source code, it doesn't seem to be possible, as the definition of white-space relevant for visual-line-mode appears to be hard-coded in the C part of the source code. I'm not sure about my conclusions, but here is the sequence of my source archaeology (I'll be linking to github for ease of reference, though when actually carrying out the ...


2

This is what you need to do (e.g., in the mode where you will be filling text): (modify-category-entry ?- ?|) That gives the hyphen character (-) the category of |, which means line breakable. Do the same for _, (, and ), if you want lines to be broken at each of those characters also. (But I suspect that you do not really want lines to be broken after ( -...


2

The command fit-window-to-buffer resizes a window, so you can type M-x fit-window-to-buffer RET to resize the current buffer's window. By default fit-window-to-buffer only resizes vertically (according to height), but you can use the variable fit-window-to-buffer-horizontally to change that: - nil (the default): only resize vertically - only: only resize ...


2

The arguments of add-hook are HOOK, FUNCTION, APPEND, and LOCAL (see quote of the docstring for add-hook below). The 1st arg in your code is 'html-mode-hook which is fine. The 2nd is (add-hook 'visual-line-mode-hook #'adaptive-wrap-prefix-mode) which is not good. It is a form that is evaluated and its return value is used as argument to add-hook. ...


2

I think what you're trying to do is: (add-hook 'html-mode-hook 'adaptive-wrap-prefix-mode) That is, add adaptive-wrap-prefix-mode directly to the html-mode hook. Adding it to visual-line-mode-hook will make it active whenever visual-line-mode is enabled, and you've enabled that globally with (global-visual-line-mode 1). Resorting to advice-add may appear ...


2

The problem was the version. I installed emacs version - 25.3 from port. Now it works. emacs-25.3 gets installed in /opt/local/bin and one can rename it so that emacs command from terminal opens it. And emacs in /usr/bin can be renamed to emacs-22 so that it can still be accessed and there is no conflict.


2

You can perform operations that are intended for buffers on strings with the help of temporary buffers. Insert the string into a temporary buffer. Switch on the desired major-mode. Insert the string contents there, Perform the operation on the temp buffer. (Here: fill-region) Return the buffer string. (Maybe with some post-processing, as, e.g., splitting at ...


1

I figured out how to do this. The relevant function is in org-indent.el, line 287: (defun org-indent-set-line-properties (level indentation &optional heading) "Set prefix properties on current line an move to next one. LEVEL is the current level of heading. INDENTATION is the expected indentation when wrapping line. When optional argument HEADING ...


1

Visual line mode does this. See the info node (emacs) Visual Line Mode in the Emacs manual for details. You can turn it on with M-x visual-line-mode.


1

How about using a stretch-glyph? (setq truncate-lines nil wrap-prefix (propertize (char-to-string ?\uE000) 'display '(space . (:width (0.5 . text))))) With this, the examples in the question now look like: and with visual-line-mode:


1

Ugh, finally figured out what I did! I hit C-x . at the end of a line -> this invokes set-fill-prefix, and applied the entire line. To undo this I moved to the beginning of a line and hit C-x . again. This cancelled the fill prefix.


1

You can split the string every 32 characters, adding them to a list: (defun split-string-every (string chars) "Split STRING into substrings of length CHARS characters. This returns a list of strings." (cond ((string-empty-p string) nil) ((< (length string) chars) (list string)) (t (cons (substring string 0 ...


1

Put this in your dotspacemacs/user-config: (defun my/enable-word-wrap () (setq-local word-wrap t)) (add-hook 'text-mode-hook #'my/enable-word-wrap) That works for me, for example, if I open a new file with SPC f f and then SPC SPC text-mode. toggle-word-wrap is an interactive command (not merely a non-interactive function) that does as it says: toggles ...


1

To avoid spelling mistakes you should try to use the kbd function for writing the keybinding. My setting therefor looks like: (global-set-key (kbd "C-x p") 'toggle-truncate-lines) because I use that keybinding globally (e.g. also in any prog-mode). For your org-mode-map -only change it would look like this: (define-key org-mode-map (kbd "s-p&...


1

A bit more manual per file but you can do do: # -*- truncate-lines: nil -*- At the top of the org-mode file.


1

self-insert-command is intended for characters that do produce themselves. it seems this is not what you want, since you want the current region (visual selection) to be to be wrapped. try something like this: (evil-define-operator wrap-with-parens (beg end) (goto-char beg) (insert "(") (goto-char (1+ end)) (insert ")")) (evil-define-key 'visual ...


Only top voted, non community-wiki answers of a minimum length are eligible