Reworking some evil keys that conflict by default.
Oh, and adding the evil-text-object designed for Python code.
This commit is contained in:
parent
85a1446ca4
commit
608ab39e07
2 changed files with 49 additions and 25 deletions
|
@ -390,12 +390,20 @@ Can we change Evil at this point? Some tips:
|
|||
(let ((mode (make-symbol (format "%s-mode" name))))
|
||||
(add-to-list 'evil-emacs-state-modes mode)))
|
||||
|
||||
;; Use escape to get out of visual mode, eh?
|
||||
;; Use escape to get out of visual mode, but hitting v again expands the selection.
|
||||
(evil-define-key 'visual global-map (kbd "v") 'er/expand-region)
|
||||
|
||||
(evil-mode))
|
||||
#+END_SRC
|
||||
|
||||
While I’m pretty good with the VIM keybindings, I would like to play around with the text objects and how it compares to others (including the surround), for instance:
|
||||
- ~diw~ :: deletes a word, but can be anywhere in it, while ~de~ deletes to the end of the word.
|
||||
- ~daw~ :: deletes a word, plus the surrounding space, but not punctuation.
|
||||
- ~xi,w~ :: changes a word that is snake or camel-cased, as in programming languages. The ~x~ can be ~c~ to change, ~d~ to delete, ~y~ to copy, etc.
|
||||
- ~xis~ :: changes a /sentence,/ and if ~i~ is ~a~, it gets rid of the surrounding whitespace as well. Probably ~das~ and ~cis~.
|
||||
- ~xip~ :: changes a /paragraph/.
|
||||
- Surrounding punctuation, like quotes, parenthesis, brackets, etc. Also work, so ~ci)~ changes all the parameters to a function call.
|
||||
|
||||
Using the key-chord project allows me to make Escape be on two key combo presses on both sides of my keyboard:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package key-chord
|
||||
|
@ -901,7 +909,7 @@ The [[https://github.com/oantolin/embark/][embark]] project offers /actions/ on
|
|||
#+END_SRC
|
||||
** Evil Snipe
|
||||
|
||||
Doom introduced me to [[https://github.com/hlissner/evil-snipe][evil-snipe]] which is similar to =f= and =t=, but does two characters, and can, when configured, search more than the current line:
|
||||
Doom introduced me to [[https://github.com/hlissner/evil-snipe][evil-snipe]] which is similar to =f= and =t=, but does two characters, and can, when configured, search more than the current line. When I use it, I stop and analyze to see the two characters to work on, so I’ve changed from the default, single ~s~, to ~g s~ so as not to get it confused with the =evil-surround=.
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package evil-snipe
|
||||
|
@ -909,45 +917,53 @@ Doom introduced me to [[https://github.com/hlissner/evil-snipe][evil-snipe]] whi
|
|||
:init
|
||||
(setq evil-snipe-scope 'visible)
|
||||
:config
|
||||
(evil-define-key '(normal motion operator visual)
|
||||
"s" #'evil-snipe-s
|
||||
"S" #'evil-snipe-S)
|
||||
(evil-snipe-mode +1))
|
||||
(evil-define-key '(normal motion operator visual) global-map
|
||||
"gs" #'evil-snipe-s
|
||||
"gS" #'evil-snipe-S))
|
||||
#+END_SRC
|
||||
|
||||
It highlights all potential matches, use ~;~ to skip to the next match, and ~,~ to jump back.
|
||||
** Evil Surround
|
||||
I like both [[https://github.com/emacs-evil/evil-surround][evil-surround]] and Henrik's [[https://github.com/hlissner/evil-snipe][evil-snipe]], however, they both start with ~s~, and conflict, and getting them to work together means I have to remember when does ~s~ call sniper and when calls surround. As an original Emacs person, I am not bound by that key history, but I do need them consistent:
|
||||
I like both [[https://github.com/emacs-evil/evil-surround][evil-surround]] and Henrik's [[https://github.com/hlissner/evil-snipe][evil-snipe]], however, they both start with ~s~, and conflict, and getting them to work together means I have to remember when does ~s~ call sniper and when calls surround. As an original Emacs person, I am not bound by that key history, but I do need them consistent, so I’m choosing the ~s~ to be /surround/.
|
||||
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package evil-surround
|
||||
:after evil-snipe
|
||||
:config
|
||||
(evil-define-key '(normal motion operator visual) evil-surround-mode-map
|
||||
"z" 'evil-surround-edit
|
||||
"Z" 'evil-Surround-edit)
|
||||
(push '(?\" . ("“" . "”")) evil-surround-pairs-alist)
|
||||
(push '(?\' . ("‘" . "’")) evil-surround-pairs-alist)
|
||||
(push '(?\` . ("`" . "'")) evil-surround-pairs-alist)
|
||||
(push '(?b . ("*" . "*")) evil-surround-pairs-alist)
|
||||
(push '(?* . ("*" . "*")) evil-surround-pairs-alist)
|
||||
(push '(?i . ("/" . "/")) evil-surround-pairs-alist)
|
||||
(push '(?/ . ("/" . "/")) evil-surround-pairs-alist)
|
||||
(push '(?= . ("=" . "=")) evil-surround-pairs-alist)
|
||||
(push '(?~ . ("~" . "~")) evil-surround-pairs-alist)
|
||||
:hook (text-mode . evil-surround-mode)) ; Don't globally use it on Magit, et. al
|
||||
#+END_SRC
|
||||
Notes:
|
||||
- ~cz'"~ :: to convert surrounding single quote string to double quotes.
|
||||
- ~dz"~ :: to delete the surrounding double quotes.
|
||||
- ~yze"~ :: puts single quotes around the next word.
|
||||
- ~yZ$<p>~ :: surrouds the line with HTML =<p>= tag (with extra carriage returns).
|
||||
- ~cs({~ :: to convert surrounding parens to curly braces.
|
||||
- ~ds"~ :: to delete the surrounding *double* quotes.
|
||||
- ~yse"~ :: puts double quotes around the next word… but only if you are at the beginning of the word, otherwise,
|
||||
- ~ysiw'~ :: puts single quotes around the word, no matter where the point is positioned.
|
||||
- ~yS$<p>~ :: surrouds the line with HTML =<p>= tag (with extra carriage returns).
|
||||
- ~(~ :: puts spaces /inside/ the surrounding parens, but ~)~ doesn't. Same with ~[~ and ~]~.
|
||||
** Jump, Jump, Jump!
|
||||
|
||||
While I grew up on =Control S=, I am liking the /mental model/ associated with the [[https://github.com/abo-abo/avy][avy project]] that allows a /jump/ among matches across all visible windows. I use the ~F18~ key on my keyboard that should be easy to use.
|
||||
While I grew up on =Control S=, I am liking the /mental model/ associated with the [[https://github.com/abo-abo/avy][avy project]] that allows a /jump/ among matches across all visible windows. I use the ~F18~ key on my keyboard that should be easy to use, but ~g o~ seems obvious.
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package avy
|
||||
:init
|
||||
(setq avy-all-windows t
|
||||
avy-single-candidate-jump t
|
||||
avy-orders-alist
|
||||
'((avy-goto-char . avy-order-closest)
|
||||
(avy-goto-word-0 . avy-order-closest)))
|
||||
:config (ha-leader "j" '("jump" . avy-goto-char-timer))
|
||||
:bind ("<f18>" . avy-goto-char-timer))
|
||||
(use-package avy
|
||||
:init
|
||||
(setq avy-all-windows t
|
||||
avy-single-candidate-jump t
|
||||
avy-orders-alist
|
||||
'((avy-goto-char . avy-order-closest)
|
||||
(avy-goto-word-0 . avy-order-closest)))
|
||||
:config (ha-leader "j" '("jump" . avy-goto-char-timer))
|
||||
(evil-define-key '(normal motion operator visual) global-map
|
||||
"go" #'avy-goto-char-timer)
|
||||
:bind ("<f18>" . avy-goto-char-timer))
|
||||
#+END_SRC
|
||||
*Note:* The links should be shorter near the point as opposed to starting from the top of the window.
|
||||
** Miscellaneous Keys
|
||||
|
|
|
@ -84,6 +84,14 @@ use_python() {
|
|||
fi
|
||||
}
|
||||
#+end_src
|
||||
** Editing Python Code
|
||||
Let’s integrate this [[https://github.com/wbolster/evil-text-object-python][Python support for evil-text-object]] project:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package evil-text-object-python
|
||||
:hook python-mode . evil-text-object-python-add-bindings)
|
||||
|
||||
#+END_SRC
|
||||
This allows me to delete a Python “block” using ~dal~.
|
||||
** Docker Environment
|
||||
Docker really allows you to isolate your project's environment. The downside is that you are using Docker and probably a bloated container. On my work laptop, a Mac, this creates a behemoth virtual machine that immediately spins the fans like a wind tunnel.
|
||||
|
||||
|
|
Loading…
Reference in a new issue