Added whitespace-mode

This commit is contained in:
Random936 2023-02-26 10:57:36 -08:00
parent ce12b329a1
commit a69e6efb10

View File

@ -6,7 +6,7 @@ There are still many improvements that I have yet to do. Here are just a few tha
* General Configuration
General configuarion is configuration of vanilla emacs. This includes making emacs minimal,
General configuarion is configuration of vanilla emacs. This includes making emacs more minimal.
** Cosmetic Configuration
@ -70,23 +70,44 @@ This function times the startup to tell you how long it took for the emacs confi
(time-subtract after-init-time before-init-time)))
gcs-done))
(add-hook 'emacs-startup-hook #'efs/display-startup-time)
(add-hook 'emacs-startup-hook 'efs/display-startup-time)
#+end_src
** White Space
This configuration replaces tabs with a custom number of spaces.
Various configuration relating to whitespace.
#+begin_src emacs-lisp
(setq-default electric-ident-inhibit t) ; Stop indentation of the previous line.
#+end_src
*** Tabs/Spaces
Disable tabs and replace them with a custom number of spaces.
#+begin_src emacs-lisp
(setq-default indent-tabs-mode nil) ; Use spaces instead of tabs.
(setq-default tab-width 3) ; Set tabs to be 3 spaces in length.
(setq-default tab-width 3)
; Alias tab width for various languages.
(setq-default c-basic-offset tab-width)
(setq-default cperl-indent-level tab-width)
(setq-default lisp-body-indent tab-width)
(setq-default lisp-indent-offset tab-width)
(setq-default js-indent-level tab-width) ; For both JSON and Javascript modes.
(setq-default evil-shift-width tab-width)
#+end_src
*** Visualizing White Space
Add a nice visualization for tabs and spaces. This can be helpful to identify which is which quickly to avoid submitting poorly spaced code.
#+begin_src emacs-lisp
(global-whitespace-mode)
(setq whitespace-global-modes '(not org-mode dired-mode))
(setq whitespace-style '(face tabs spaces tab-mark space-mark trailing))
(custom-set-faces
'(whitespace-tab ((t (:foreground "#384551" :background nil))))
'(whitespace-space ((t (:foreground "#384551" :background nil)))))
(setq whitespace-display-mappings
'((tab-mark 9 [187 9] [92 9])
(space-mark 32 [183] [46])))
#+end_src
* Packages