I want to enter the tab as it is in Emacs

Asked 2 years ago, Updated 2 years ago, 92 views

I use Emacs 25.2.1 in FreeBSD, but
in fundamental-mode I'd like to enter the tab as it is. How do I set it up?

Now it's a space or trying to continue indenting the last line.
I'd like to disable this.

I wrote (electric-indent-mode-1) in .emacs, but it doesn't work.
Thank you for your cooperation.

emacs

2022-09-30 21:24

2 Answers

C-q (M-xquoted-insert) allows you to insert the following keystrokes directly into the buffer:Tab input is C-q<TAB>.

If you want to treat the TAB key as a tab input, add the following settings to .emacs (or ~/.emacs.d/init.el).However, this behavior may not be intended because it is enabled in all major modes.

; Enable tab indentation
(setq-default indent-tabs-mode t)

;; If you want to enable text mode only, you can write like this.
(add-hook'text-mode-hook(lambda() (setq indent-tabs-mode t)))

f Since fundamental-mode is handled differently from other major modes, it is a little troublesome to rewrite the configuration only for this mode.If there is a demand in the comments, I will add it.


2022-09-30 21:24

Use defadvice as a separate solution.

 (defadvice fundamental-mode (after insert-tab-char-as-is activate)
  (local-set-key(kbd "TAB") (lambda()(interactive)(insert?\t)))


2022-09-30 21:24

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.