3/24/2023 0 Comments Emacs auto indent![]() ![]() Something that was driving me nuts was Emacs electric-indent indenting the previous line when I press enter. Making Indentation Behave Sanely (Electric Indent) ( setq backward-delete-char-untabify-method 'hungry ) (OPTIONAL) Shift width for evil-mode users For the vim-like motions of ">" and "> or << motion to indent or de-indent text. START TABS CONFIG Create a variable for our preferred tab width ( setq custom-tab-width 2 ) 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 ) 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. To learn how to customize tabs and spaces behavior differently, please refer to the Breaking It Down section. This configuration is meant for users that prefer tabs over spaces. Highlighting Tabs and Spaces Differently.Making Indentation Behave Sanely (Electric Indent).Using Tabs or Spaces in Different Files. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |