From 5c2da67e15edbf7904f710c8df72692cf6eaa5d6 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Sat, 30 Jan 2021 00:23:34 +0100 Subject: [PATCH] Add little quality of life functions for evil --- .config/emacs/config.org | 58 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/.config/emacs/config.org b/.config/emacs/config.org index 1024326..e6973e3 100644 --- a/.config/emacs/config.org +++ b/.config/emacs/config.org @@ -62,6 +62,7 @@ - [[#package-functions][Package Functions]] - [[#centaur-tabs-functions][Centaur Tabs Functions]] - [[#dashboard-functions][Dashboard Functions]] + - [[#evil-functions][Evil functions]] - [[#lsp-functions][LSP Functions]] - [[#neotree-functions][Neotree Functions]] - [[#org-functions][Org Functions]] @@ -1229,6 +1230,49 @@ Fix keybinds.. (funcall (local-key-binding "r"))) #+END_SRC +*** Evil functions + +#+BEGIN_SRC emacs-lisp +(defun dot/evil-copy-until-end-of-line () + "Copy text until the end of the line. + +Vim equivalence: y$" + (interactive) + (evil-yank (point) (line-end-position))) + +(defun dot/evil-insert-shift-left () + "Shift line left, retains cursor position. + +Vim equivalence: " + (interactive) + (evil-shift-left (line-beginning-position) (line-end-position))) + +(defun dot/evil-visual-paste () + "Paste over visual selection, retains clipboards contents. + +Vim equivalence: pgvy" + (interactive) + (call-interactively 'evil-paste-after) + (evil-visual-restore) + (call-interactively 'evil-yank)) + +(defun dot/evil-visual-shift-left () + "Shift visual selection left, retains the selection. + +Vim equivalence: gv" + (interactive) + (evil-shift-right (region-beginning) (region-end)) + (funcall (evil-visual-restore))) +#+END_SRC + *** LSP Functions #+BEGIN_SRC emacs-lisp @@ -1502,9 +1546,21 @@ Set keybinds to functionality of installed packages. ;https://github.com/noctuid/evil-guide#global-keybindings-and-evil-states (with-eval-after-load 'evil-states + ;; Global evil keymap + (general-def evil-normal-state-map - "C-n" 'neotree-toggle-in-project-root) + "Y" #'dot/evil-copy-until-end-of-line ;; y$ + "C-S-p" #'evil-paste-pop-next + "C-n" #'neotree-toggle-in-project-root) + + (general-def evil-insert-state-map + "" #'dot/evil-insert-shift-left) ;; << + + (general-def evil-visual-state-map + "p" #'dot/evil-visual-paste ;; pgvy + "<" #'dot/evil-visual-shift-left ;; " #'dot/evil-visual-shift-right) ;; >gv ;; Custom (M-x customize) (general-def 'normal custom-mode-map