evil
evil copied to clipboard
How to make o/O use 4 spaces or a tab, it does 2 spaces.
Issue type
- Question
Environment
Emacs version: GNU Emacs 29.4 (build 3, x86_64-pc-linux-gnu, X toolkit, cairo version 1.18.0, Xaw3d scroll \ bars) of 2024-10-07
Operating System: WSL2 + Ubuntu-24.04
Evil version: Evil version 1.15.0
Evil installation type: Elpaca
Graphical/Terminal: terminal-emulator (wsltty)
Tested in a make emacs
session (see CONTRIBUTING.md):
Reproduction steps
- Start Emacs
Open a C++ file. Go to a line. Press o.
Expected behavior
I want it so that it either inserts a tab (size: 4) in the next line or 4 spaces.
Actual behavior
Inserts 2 spaces.
Further notes
Noob tries to do stuff with tabs. Why is this so difficult.
; START TABS CONFIG
;; Create a variable for our preferred tab width
(setq custom-tab-width 4)
;; Two callable functions for enabling/disabling tabs in Emacs
(defun disable-tabs () (setq indent-tabs-mode nil))
(defun enable-tabs ()
(local-set-key (kbd "TAB") 'tab-to-tab-stop)
(setq indent-tabs-mode t)
(setq tab-width custom-tab-width))
;; Hooks to Enable Tabs
(add-hook 'prog-mode-hook 'enable-tabs)
;; Hooks to Disable Tabs
(add-hook 'lisp-mode-hook 'disable-tabs)
(add-hook 'emacs-lisp-mode-hook 'disable-tabs)
(add-hook 'c++-ts-mode-hook 'enable-tabs)
(add-hook 'c-ts-mode-hook 'enable-tabs)
;; Language-Specific Tweaks
(setq-default python-indent-offset custom-tab-width) ;; Python
(setq-default js-indent-level custom-tab-width) ;; Javascript
;; Making electric-indent behave sanely
(setq-default electric-indent-inhibit t)
;; Make the backspace properly erase the tab instead of
;; removing 1 space at a time.
(setq backward-delete-char-untabify-method 'hungry)
;; (OPTIONAL) Shift width for evil-mode users
;; For the vim-like motions of ">>" and "<<".
(setq-default evil-shift-width custom-tab-width)
(setq-default c-basic-offset custom-tab-width)
(setq-default standard-indent custom-tab-width)
;; WARNING: This will change your life
;; (OPTIONAL) Visualize tabs as a pipe character - "|"
;; This will also show trailing characters as they are useful to spot.
(setq whitespace-style '(face tabs tab-mark trailing))
(custom-set-faces
'(whitespace-tab ((t (:foreground "#636363")))))
(setq whitespace-display-mappings
'((tab-mark 9 [124 9] [92 9]))) ; 124 is the ascii ID for '\|'
(global-whitespace-mode) ; Enable whitespace mode everywhere
; END TABS CONFIG
I am using evil-collection and evil. I have no clue what to do. Read manuals but cannot wrap my head around which option to set/unset.