Last active
January 7, 2026 14:14
-
-
Save jargnar/e9267e0abcd9de8ca8a6b48d1f3e22eb to your computer and use it in GitHub Desktop.
.emacs.d/init.el
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (tool-bar-mode -1) | |
| (load-theme 'tsdh-dark t) | |
| (ido-mode 1) | |
| (ido-everywhere 1) | |
| (global-display-line-numbers-mode 1) | |
| (setq initial-buffer-choice #'eshell) | |
| (defalias 'eshell/e 'find-file) | |
| (defalias 'eshell/d 'dired) | |
| (when (eq system-type 'darwin) | |
| (setq ns-command-modifier 'control) | |
| (setq ns-control-modifier 'super)) | |
| (global-set-key (kbd "s-<left>") #'windmove-left) | |
| (global-set-key (kbd "s-<right>") #'windmove-right) | |
| (global-set-key (kbd "s-<up>") #'windmove-up) | |
| (global-set-key (kbd "s-<down>") #'windmove-down) | |
| (global-set-key (kbd "s-S-<left>") #'windmove-swap-states-left) | |
| (global-set-key (kbd "s-S-<right>") #'windmove-swap-states-right) | |
| (global-set-key (kbd "s-S-<up>") #'windmove-swap-states-up) | |
| (global-set-key (kbd "s-S-<down>") #'windmove-swap-states-down) | |
| (custom-set-variables | |
| ;; custom-set-variables was added by Custom. | |
| ;; If you edit it by hand, you could mess it up, so be careful. | |
| ;; Your init file should contain only one such instance. | |
| ;; If there is more than one, they won't work right. | |
| '(package-selected-packages '(evil))) | |
| (custom-set-faces | |
| ;; custom-set-faces was added by Custom. | |
| ;; If you edit it by hand, you could mess it up, so be careful. | |
| ;; Your init file should contain only one such instance. | |
| ;; If there is more than one, they won't work right. | |
| ) | |
| (require 'evil) | |
| (evil-mode 1) | |
| ;;; Wdired evil configuration | |
| (with-eval-after-load 'dired | |
| (define-key dired-mode-map [mouse-2] 'dired-mouse-find-file)) | |
| ;;; Evil vim-like buffer commands | |
| (with-eval-after-load 'evil | |
| (evil-ex-define-cmd "w" 'my/evil-write) | |
| (evil-ex-define-cmd "q" 'my/evil-quit) | |
| (evil-ex-define-cmd "q!" 'kill-current-buffer) | |
| (evil-ex-define-cmd "wq" 'my/evil-write-quit)) | |
| (defun my/evil-write () | |
| "Save buffer, prompt for filename if none." | |
| (interactive) | |
| (if (buffer-file-name) | |
| (save-buffer) | |
| (call-interactively 'write-file))) | |
| (defun my/evil-quit () | |
| "Kill buffer, prompt if modified." | |
| (interactive) | |
| (if (and (buffer-modified-p) (buffer-file-name)) | |
| (if (y-or-n-p "Buffer modified. Kill anyway? ") | |
| (kill-current-buffer) | |
| (message "Aborted")) | |
| (kill-current-buffer))) | |
| (defun my/evil-write-quit () | |
| "Save and kill buffer." | |
| (interactive) | |
| (my/evil-write) | |
| (kill-current-buffer)) | |
| ;;; Wdired vim-like editing | |
| (with-eval-after-load 'dired | |
| (require 'wdired) | |
| (evil-define-key 'normal dired-mode-map "i" | |
| (lambda () | |
| (interactive) | |
| (wdired-change-to-wdired-mode) | |
| (evil-insert-state))) | |
| (add-hook 'wdired-mode-hook 'my/wdired-setup)) | |
| (defun my/wdired-setup () | |
| "Setup vim-like bindings for wdired." | |
| (setq-local evil-ex-commands | |
| (append '(("w" . wdired-finish-edit) | |
| ("wq" . wdired-finish-edit) | |
| ("q" . my/wdired-quit) | |
| ("q!" . my/wdired-abort)) | |
| evil-ex-commands))) | |
| (defun my/wdired-quit () | |
| "Quit wdired, prompt if modified. Fall back to global if not in wdired." | |
| (interactive) | |
| (if (not (derived-mode-p 'wdired-mode)) | |
| (my/evil-quit) | |
| (if (buffer-modified-p) | |
| (when (y-or-n-p "Discard changes? ") | |
| (wdired-abort-changes)) | |
| (wdired-abort-changes)))) | |
| (defun my/wdired-abort () | |
| "Abort wdired. Fall back to global if not in wdired." | |
| (interactive) | |
| (if (derived-mode-p 'wdired-mode) | |
| (wdired-abort-changes) | |
| (kill-current-buffer))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment