diff options
| author | Miquel Sabaté Solà <msabate@suse.com> | 2019-01-15 08:49:08 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <msabate@suse.com> | 2019-01-15 08:55:08 +0100 |
| commit | 84fb463326379d14af4944a5b0d9c926980c022d (patch) | |
| tree | a1e506125a7cbb42fe5bbd401e946ed11de7cf78 /emacs/init.org | |
| parent | 60c7d2d3841032421e203b9c5efae4a65accb98e (diff) | |
| download | dotfiles-84fb463326379d14af4944a5b0d9c926980c022d.tar.gz dotfiles-84fb463326379d14af4944a5b0d9c926980c022d.zip | |
emacs: bringing back C-a and C-e
I'm bringing back the default Emacs' bindings for C-a and C-e. The idea
is that these bindings actually make more sense than the Vim ones. These
caused two conflicts:
1. The `expand-region` package was already using the C-e binding. I've
simply removed this package, because in these years I've never used
it, so I guess it's not for me.
2. The `evil-numbers/inc-at-pt` package was already using the C-a
binding. I do use this one, but I moved it into C-c +, which is
similar to what I already use for `evil-numbers/dec-at-pt`. It's not
too bad if I have to do it once (and if I have to repeat it there's
always `.`).
Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
Diffstat (limited to 'emacs/init.org')
| -rw-r--r-- | emacs/init.org | 43 |
1 files changed, 11 insertions, 32 deletions
diff --git a/emacs/init.org b/emacs/init.org index 224ee3a..e15d9cc 100644 --- a/emacs/init.org +++ b/emacs/init.org @@ -689,34 +689,6 @@ that often, but it's cool to have a distraction-free screen from time to time. :ensure t) #+END_SRC -The =expand-region= package is an extension that is based on a Vim one, which -expands the region of selection with a single key chord. Even if evil covers -most of my uses, it's convenient to have this tool anyways. - -#+BEGIN_SRC elisp -(use-package expand-region - :ensure t - :config - - ; Set C-e as the expand command (mnemonic: expand). This command will - ; supercede the evil binding for "move one line", which I never use anyways. - (global-set-key (kbd "\C-e") 'er/expand-region) - (with-eval-after-load 'evil - (define-key evil-normal-state-map (kbd "\C-e") 'er/expand-region) - (define-key evil-visual-state-map (kbd "\C-e") 'er/expand-region))) - -(defun er/add-text-mode-expansions () - "This way we can also expand the region into paragraphs & pages in text mode. -Directly taken from: https://github.com/magnars/expand-region.el." - - (set (make-local-variable 'er/try-expand-list) (append - er/try-expand-list - '(mark-paragraph - mark-page)))) - -(add-hook 'text-mode-hook 'er/add-text-mode-expansions) -#+END_SRC - Editing files as root is a bit of a pain because usually the root user doesn't have the same configuration as the current one, and attempting to do so can be messy. So, instead of that, we could advice the =find-file= function so if the @@ -839,6 +811,14 @@ First of all, let's define a function that will be called whenever Evil is loade (global-unset-key (kbd "M-j")) (global-unset-key (kbd "M-k")) + ; Go back to Emacs' bindings on beginning/end of line. + (eval-after-load "evil-maps" + (dolist (map '(evil-motion-state-map + evil-insert-state-map + evil-emacs-state-map)) + (define-key (eval map) "\C-a" 'beginning-of-line) + (define-key (eval map) "\C-e" 'end-of-line))) + ; both this function and the subsequent lines about [escape] are taken from ; @aaronbieber configuration. (defun minibuffer-keyboard-quit () @@ -969,15 +949,14 @@ respectively. #+END_SRC Last but not least, =evil-numbers= brings a couple of bindings available to Vim -into Evil: @@html:<kbd>C-a</kbd>@@ for increasing a number, and -@@html:<kbd>C-c -</kbd>@@ for decreasing it (modified because -@@html:<kbd>C-z</kbd>@@ is my escape sequence). +into Evil: @@html:<kbd>C-c +</kbd>@@ for increasing a number, and +@@html:<kbd>C-c -</kbd>@@ for decreasing it. #+BEGIN_SRC elisp (use-package evil-numbers :ensure t :config - (define-key evil-normal-state-map (kbd "C-a") 'evil-numbers/inc-at-pt) + (define-key evil-normal-state-map (kbd "C-c +") 'evil-numbers/inc-at-pt) (define-key evil-normal-state-map (kbd "C-c -") 'evil-numbers/dec-at-pt))) #+END_SRC |
