You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+33Lines changed: 33 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -51,6 +51,7 @@ In addition to *minimal-emacs.d*, startup speed is influenced by your computer's
51
51
-[How to enable the menu-bar, the tool-bar, dialogs, the contextual menu, and tooltips?](#how-to-enable-the-menu-bar-the-tool-bar-dialogs-the-contextual-menu-and-tooltips)
-[Automatic removal of trailing whitespace on save](#automatic-removal-of-trailing-whitespace-on-save)
54
55
-[How to activate recentf, savehist, saveplace, and auto-revert?](#how-to-activate-recentf-savehist-saveplace-and-auto-revert)
55
56
-[Activating autosave](#activating-autosave)
56
57
-[auto-save-mode (Prevent data loss in case of crashes)](#auto-save-mode-prevent-data-loss-in-case-of-crashes)
@@ -226,6 +227,38 @@ Native compilation enhances Emacs performance by converting Elisp code into nati
226
227
(compile-angel-on-load-mode))
227
228
```
228
229
230
+
### Automatic removal of trailing whitespace on save
231
+
232
+
**Trailing whitespace** refers to any spaces or tabs that appear after the last non-whitespace character on a line. These characters have no semantic value and can lead to unnecessary diffs in version control, inconsistent formatting, or visual clutter. Removing them improves code clarity and consistency.
233
+
234
+
The **stripspace** Emacs package provides `stripspace-local-mode`, a minor mode that automatically removes trailing whitespace and blank lines at the end of the buffer when saving.
235
+
236
+
To enable **stripspace** and automatically delete trailing whitespace, add the following configuration to `~/.emacs.d/post-init.el`:
237
+
```elisp
238
+
(use-package stripspace
239
+
:ensure t
240
+
241
+
;; Enable for prog-mode-hook, text-mode-hook, conf-mode-hook
242
+
:hook ((prog-mode . stripspace-local-mode)
243
+
(text-mode . stripspace-local-mode)
244
+
(conf-mode . stripspace-local-mode))
245
+
246
+
:custom
247
+
;; The `stripspace-only-if-initially-clean' option:
248
+
;; - nil to always delete trailing whitespace.
249
+
;; - Non-nil to only delete whitespace when the buffer is clean initially.
250
+
;; (The initial cleanliness check is performed when `stripspace-local-mode'
251
+
;; is enabled.)
252
+
(stripspace-only-if-initially-clean nil)
253
+
254
+
;; Enabling `stripspace-restore-column' preserves the cursor's column position
255
+
;; even after stripping spaces. This is useful in scenarios where you add
256
+
;; extra spaces and then save the file. Although the spaces are removed in the
257
+
;; saved file, the cursor remains in the same position, ensuring a consistent
258
+
;; editing experience without affecting cursor placement.
259
+
(stripspace-restore-column t))
260
+
```
261
+
229
262
### How to activate recentf, savehist, saveplace, and auto-revert?
230
263
231
264
The recentf, savehist, saveplace, and auto-revert built-in packages are already configured by *minimal-emacs.d*. All you need to do is activate them by adding the following to `~/.emacs.d/post-init.el`:
0 commit comments