2022-03-28 15:03:21 +02:00
|
|
|
#+title: :editor word-wrap
|
|
|
|
#+subtitle: Soft-wrapping with language-aware indent
|
|
|
|
#+created: August 25, 2019
|
|
|
|
#+since: 21.12.0 (#1709)
|
2021-10-16 01:22:41 +02:00
|
|
|
|
|
|
|
* Description :unfold:
|
2022-09-26 02:19:42 +08:00
|
|
|
This module adds a minor-mode [[fn:+word-wrap-mode]], which intelligently wraps long
|
2019-08-26 00:53:18 +10:00
|
|
|
lines in the buffer without modifying the buffer content.
|
|
|
|
|
2021-10-16 01:22:41 +02:00
|
|
|
** Maintainers
|
|
|
|
- [[doom-user:][@flatwhatson]]
|
|
|
|
|
|
|
|
[[doom-contrib-maintainer:][Become a maintainer?]]
|
2019-08-26 00:53:18 +10:00
|
|
|
|
2021-10-16 01:22:41 +02:00
|
|
|
** Module flags
|
|
|
|
/This module has no flags./
|
2019-08-26 00:53:18 +10:00
|
|
|
|
2021-10-16 01:22:41 +02:00
|
|
|
** Packages
|
2022-09-26 02:19:42 +08:00
|
|
|
- [[doom-package:adaptive-wrap]]
|
2022-11-02 16:27:46 +01:00
|
|
|
- [[doom-package:visual-fill-column]]
|
2019-08-26 00:53:18 +10:00
|
|
|
|
2021-10-16 01:22:41 +02:00
|
|
|
** Hacks
|
|
|
|
/No hacks documented for this module./
|
2019-10-15 00:51:28 +10:00
|
|
|
|
2021-10-16 01:22:41 +02:00
|
|
|
** TODO Changelog
|
|
|
|
# This section will be machine generated. Don't edit it by hand.
|
|
|
|
/This module does not have a changelog yet./
|
|
|
|
|
|
|
|
* Installation
|
|
|
|
[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]]
|
2019-10-15 00:51:28 +10:00
|
|
|
|
2021-10-16 01:22:41 +02:00
|
|
|
/This module has no external requirements./
|
2019-08-26 00:53:18 +10:00
|
|
|
|
2021-10-16 01:22:41 +02:00
|
|
|
* TODO Usage
|
|
|
|
#+begin_quote
|
2023-09-16 20:19:11 +02:00
|
|
|
This module has no usage documentation yet. [[doom-contrib-module:][Write some?]]
|
2021-10-16 01:22:41 +02:00
|
|
|
#+end_quote
|
2019-08-26 00:53:18 +10:00
|
|
|
|
2021-10-16 01:22:41 +02:00
|
|
|
* TODO Configuration
|
|
|
|
#+begin_quote
|
2023-09-16 20:19:11 +02:00
|
|
|
/This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]]
|
2021-10-16 01:22:41 +02:00
|
|
|
#+end_quote
|
|
|
|
|
|
|
|
** Activation
|
2019-08-26 00:53:18 +10:00
|
|
|
Word wrapping is not enabled by default.
|
|
|
|
|
|
|
|
Wrapping can be toggled in the current buffer with ~M-x +word-wrap-mode~. The
|
2021-10-16 01:22:41 +02:00
|
|
|
default doom bindings bind this to [[kbd:][SPC t w]] for ~evil~ users.
|
2019-08-26 00:53:18 +10:00
|
|
|
|
2022-11-02 16:27:46 +01:00
|
|
|
To enable wrapping in a specific mode, add it to the appropriate hook in
|
|
|
|
~$DOOMDIR/config.el~:
|
2021-10-16 01:22:41 +02:00
|
|
|
#+begin_src emacs-lisp
|
2019-08-26 00:53:18 +10:00
|
|
|
;; enable word-wrap in C/C++/ObjC/Java
|
|
|
|
(add-hook 'c-mode-common-hook #'+word-wrap-mode)
|
2021-10-16 01:22:41 +02:00
|
|
|
#+end_src
|
2019-08-26 00:53:18 +10:00
|
|
|
|
2019-10-15 00:51:28 +10:00
|
|
|
To customize the behaviour in a specific mode:
|
2021-10-16 01:22:41 +02:00
|
|
|
#+begin_src emacs-lisp
|
2022-11-02 16:27:46 +01:00
|
|
|
;; use a single indent and wrap at fill-column in json-mode
|
2019-10-15 00:51:28 +10:00
|
|
|
(add-hook! 'json-mode-hook
|
2022-11-02 16:27:46 +01:00
|
|
|
(setq-local +word-wrap-extra-indent 'single
|
|
|
|
+word-wrap-fill-style 'soft)
|
2019-08-26 00:53:18 +10:00
|
|
|
(+word-wrap-mode +1))
|
2021-10-16 01:22:41 +02:00
|
|
|
#+end_src
|
2019-08-26 00:53:18 +10:00
|
|
|
|
|
|
|
To turn on word wrapping (almost) everywhere:
|
2021-10-16 01:22:41 +02:00
|
|
|
#+begin_src emacs-lisp
|
2019-08-26 00:53:18 +10:00
|
|
|
;; enable word-wrap (almost) everywhere
|
|
|
|
(+global-word-wrap-mode +1)
|
2021-10-16 01:22:41 +02:00
|
|
|
#+end_src
|
2019-08-26 00:53:18 +10:00
|
|
|
|
|
|
|
To disable global word-wrapping in a specific mode:
|
2021-10-16 01:22:41 +02:00
|
|
|
#+begin_src emacs-lisp
|
2019-08-26 00:53:18 +10:00
|
|
|
;; disable global word-wrap in emacs-lisp-mode
|
|
|
|
(add-to-list '+word-wrap-disabled-modes 'emacs-lisp-mode)
|
2021-10-16 01:22:41 +02:00
|
|
|
#+end_src
|
|
|
|
|
|
|
|
** Settings
|
|
|
|
Wrapped lines will be indented to match the preceding line. In code buffers,
|
|
|
|
lines which are not inside a string or comment will have extra indentation as
|
|
|
|
determined by ~+word-wrap-extra-indent~. The default is to increase the indent
|
|
|
|
by twice the major-mode indent.
|
|
|
|
|
|
|
|
The ~+word-wrap-extra-indent~ variable supports the following values:
|
|
|
|
- ~double~: indent by twice the major-mode indentation
|
|
|
|
- ~single~: indent by the major-mode indentation
|
|
|
|
- a positive integer: indent by this fixed amount
|
|
|
|
- a negative integer: dedent by this fixed amount
|
|
|
|
- ~nil~: no extra indent
|
|
|
|
|
2022-11-02 16:27:46 +01:00
|
|
|
Long lines are wrapped at the window margin by default, however soft-wrapping at
|
|
|
|
~fill-column~ is supported by setting ~+word-wrap-fill-style~. When set to
|
|
|
|
~auto~, if ~auto-fill-mode~ is enabled in the buffer, its behavior will not be
|
|
|
|
affected. This allows hard and soft wrapping methods to co-exist, with
|
|
|
|
hard-wrapping for new lines and soft-wrapping for existing lines. To disable
|
|
|
|
hard-wrapping entirely, set ~+word-wrap-fill-style~ to ~soft~.
|
|
|
|
|
2021-10-16 01:22:41 +02:00
|
|
|
This module also includes a global minor-mode ~+global-word-wrap-mode~ to
|
|
|
|
automatically enable wrapping in most buffers. Wrapping will not be enabled in
|
|
|
|
buffers whose major mode is marked "special", or are listed in
|
|
|
|
~+word-wrap-disabled-modes~.
|
|
|
|
|
|
|
|
The ~+word-wrap-text-modes~ variable lists modes which shouldn't have any extra
|
|
|
|
indentation, regardless of the ~+word-wrap-extra-indent~ setting. This is useful
|
|
|
|
for modes which are primarily text, such as ~text-mode~ and ~markdown-mode~.
|
|
|
|
|
|
|
|
The ~+word-wrap-visual-modes~ variable lists modes which should only enable
|
|
|
|
~visual-line-mode~ and not provide any prefix indentation. This is useful for
|
|
|
|
modes like ~org-mode~ which handle prefix indentation themselves.
|
|
|
|
|
|
|
|
* Troubleshooting
|
|
|
|
/There are no known problems with this module./ [[doom-report:][Report one?]]
|
|
|
|
|
|
|
|
* Frequently asked questions
|
|
|
|
/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]]
|
|
|
|
|
|
|
|
* TODO Appendix
|
|
|
|
#+begin_quote
|
2023-09-16 20:19:11 +02:00
|
|
|
This module has no appendix yet. [[doom-contrib-module:][Write one?]]
|
2021-10-16 01:22:41 +02:00
|
|
|
#+end_quote
|