5

The elisp manual section about auto-filling describes the auto-fill-chars variable. -- Variable: auto-fill-chars A char table of characters which invoke ‘auto-fill-function’ when self-inserted—space and newline in most language environments. They have an entry ‘t’ in the table. About char tables it says: A char-table is much like a vector, except ...


4

If you don't mind filling paragraphs rather than just individual sentences, the simplest way to do it is probably to select the entire buffer and use fill-region. Here's a simple command that will automate the process: (defun fill-buffer () (interactive) (save-excursion (save-restriction (widen) (fill-region (point-min) (point-max)))))


4

Based on the docstrings of the commands, you probably want something along the lines of: (defun fill-sentence () (interactive) ;; optional ;; (save-excursion (backward-sentence) (push-mark) (forward-sentence) (fill-region (point) (mark)) ;; ) ) The optional save-excursion (and commented )) will keep the point where you started (so can be ...


4

This is expected Vim behavior. One way to fix this is to just switch to d e instead of d w when you get to the EOL (which I recommend), or you can make that switch automatic: (defun nadvice/evil-forward-word-begin (old-fun &rest args) (if (looking-at "[[:space:]]*$") (progn (apply #'evil-forward-word-end args) ;; fix off-by-one ...


3

You have sentence-end-double-space set to its default value, which is t. The relevant part of the docstring: Documentation: Non-nil means a single space does not end a sentence. This is relevant for filling. See also sentence-end-without-period and colon-double-space. That variable needs to be set to nil to get the wrapping you expect. So: (...


3

This will work: (add-hook 'org-mode-hook '(lambda () (setq fill-column 80))) (add-hook 'org-mode-hook 'auto-fill-mode) It enables a minor mode called auto-fill-mode that does exactly what you asked and sets the column where the line break happens to 80 (only for org-mode!). EDIT: To be consistent with Emacs Manual you could use (add-hook 'org-mode-hook '...


3

You could modify the category of characters G, C, A, and T to make them line-breakable: (defun break-at-gcat () "Make characters G, C, A, and T line-breakable to simplify wrapping DNA sequence strings." (dolist (char '(?G ?C ?A ?T)) (modify-category-entry char ?|))) Now if I evaluate (break-at-gcat), set fill-column to 20, (setq-local fill-column ...


3

You can add the following lines to your init-file. Additionally to the default setting, they define lines consisting of at least two equal non-alphanumerical characters as paragraph start and delimiter. (setq paragraph-start "^\\([^[:alnum:]]\\)\\1+\n\\|\f\\|[ ]*$") (setq paragraph-separate "\\([^[:alnum:]]\\)\\1+\n\\|[ \f]*$") Alternatively, you can ...


2

Yes, you want visual-line-mode. See the Emacs manual section 14.22 (run M-: (info "(emacs)Visual Line Mode") to jump right to it inside Emacs).


2

This should do it: (add-hook 'org-mode-hook (lambda () (setq fill-column 100)))


2

From the auto-fill-mode docs: When Auto Fill mode is enabled, inserting a space at a column beyond `current-fill-column' automatically breaks the line at a previous space. So if you e.g., type a continuous string starting from column 1 to column 100, it will not break at 80 even if you set fill-column to 80. However, if you enter a space at any point ...


2

You didn't mention which major mode this happens in, but I can see the problem using c-mode. Here is an (abridged) backtrace which you can get after setting debug-on-error: Debugger entered--Lisp error: (args-out-of-range #<buffer xx> 66 66)... buffer-substring(#<marker at 66 in xx> #<marker at 66 in xx>) yas--field-text-for-display([...


2

When some key sequence triggers an unexpected command, use view-lossage (bound to C-h lby default) to see what keystrokes Emacs has recently received. This is most useful since Emacs 25 as it now shows the commands invoked by each key sequence -- in earlier releases you'll just see the raw keystrokes. When an unexpected minor-mode has been enabled, use ...


2

Prevent hooks from parent mode in derived mode Not trivial. I certainly can't think of a nice approach. You may find https://stackoverflow.com/a/19295380 of interest, though. How can I disable auto-fill for nxml? The trivial approach is to simply switch it off in nxml-mode-hook. The mode will be switched on, and almost immediately switched off again. (...


2

The directory local variables are set after the major mode command run. Otherwise the major-mode dependent file local variables would not work. Therefore, you just buffer-locally add turn-on-auto-fill to text-mode-hook. But the hook is not run again and your configuration is without effect. If you want to deactivate truncate-lines for all major modes and ...


2

If you want to globally set auto-fill-mode, as you say, the solution would be to put this in your .emacs.s/init.el (or equivalent): (add-hook 'org-mode-hook 'turn-on-auto-fill) This means that all files that are viewed in org-mode (usually, files ending in .org) will have auto-fill-mode switched on. If you do that, you will only use @Tyler's answer once:...


1

As DoMiNeLa10♦ metioned, lsp-mode can do this: You should install typescript-language-server in your system and lsp-mode, js2-mode, autocomplete in your emacs. You can check these link for more details. https://github.com/emacs-lsp/lsp-mode https://emacs-china.org/t/tide-javascript/7068 Or you can check my emacs.d file: https://github.com/RezoChiang/...


1

This is the expected behaviour as resulted from the emacs manual: When Auto Fill mode breaks a line, it tries to obey the adaptive fill prefix: if a fill prefix can be deduced from the first and/or second line of the current paragraph, it is inserted into the new line (see Adaptive Fill). Otherwise the new line is indented, as though you had typed on it (...


1

If you want to fill all the lines in a region, use the command M-x fill-region. To mark the entire buffer (so the region includes the entire file), use the command M-x mark-whole-buffer, which is also bound to the keybinding C-x h. If you only want to temporarily wrap the lines for easier reading, you can use visual-line-mode, combined with visual-fill-...


1

auto-fill-mode is what you look for. You can type M-x auto-fill-mode to toggle it to be enabled, then type SPC to let it do filling automatically after copying/yanking the content.


1

I had comment-auto-fill-only-comments set to t. Since Magit commit buffer supports comments, it won't auto-fill. (use-package git-commit   :ensure nil   :preface   (defun me/git-commit-set-fill-column ()     (setq-local comment-auto-fill-only-comments nil)     (setq fill-column 72))   :config   (advice-add 'git-commit-turn-on-auto-fill :before #'me/git-...


1

Operator Error: After getting a suggestion from @Dan ( emacs -Q ), I tried org-mode again. With distractions out of the way it became clear that headers and paragraphs are treated differently. I was expecting a header to wrap, but they don't. Paragraphs are wrapping just fine with no fixes required.


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