practicalli / spacemacs

Content for the book - Clojure Development with Spacemacs
https://practical.li/spacemacs
Creative Commons Attribution Share Alike 4.0 International
110 stars 33 forks source link

Evil: hyphen as a word character or navigate via symbols #196

Open practicalli-johnny opened 4 years ago

practicalli-johnny commented 4 years ago

In Clojure kebab-case is used for names of symbols.

Some Evil commands work on words, so would treat kebab-case as three separate words, kebab, - and case.

It is possible to over-ride which characters Evil considers as word characters

(modify-syntax-entry ?- "w")

Note: there does seem to be an issue with this approach, with w calling forward word getting stuck on closing parens

motion by symbols is more convenient than motion by words, especially for Clojure.

To make word motions operate as symbol motions alias the evil-word thing [1] to the evil-symbol thing:

(defalias 'forward-evil-word 'forward-evil-symbol)

Footnotes [1] Many of Evil’s text objects and motions are defined in terms of the thingatpt library, which in this case are defined entirely in terms of forward-THING functions. Thus aliasing one to another should make all motions and text objects implemented in terms of that thing behave the same.

https://evil.readthedocs.io/en/latest/faq.html#underscore-is-not-a-word-character