evil
evil copied to clipboard
Word commands do not respect word boundaries of the current syntax table
Originally reported by: Mika Vilpas (Bitbucket: sp3ctum, GitHub: sp3ctum)
Commands operating on words, such as w
and *
, don't seem to respect the syntax table of the current mode for me. In this isssue it is described to alter the syntax table to include, for example, dashes (-) as being part of a word: https://bitbucket.org/lyro/evil/issues/222/w-command-is-not-compatibile-with-vims
I have this in my config:
;; http://timothypratley.blogspot.fi/2014/08/clojure-friendly-word-definitions-in.html
;; Treat these characters as word characters. Works great with evil-mode!
(dolist (c (string-to-list ":_-?!#*"))
(modify-syntax-entry c "w" clojure-mode-syntax-table)
(modify-syntax-entry c "w" emacs-lisp-mode-syntax-table))
This used to work in evil-20141003.1015, but now I've upgraded to evil-20150818.1313 and the functionality is broken for me. Is there a way to work around this? Have I misconfigured somehow?
- Bitbucket: https://bitbucket.org/lyro/evil/issue/565
Original comment by sykora NA (Bitbucket: sykora, GitHub: sykora):
I just upgraded to emacs 25.1, and I can confirm that something's going on with word selection.
Suppose I have the following text (with cursor between the |'s):
#!emacs-lisp
;; This buffer is for te|x|t that is not saved, and for Lisp evaluation.
Then pressing viw
selects all the following text (between |s):
#!emacs-lisp
;;| This buffer is for text that is not saved|, and for Lisp evaluation.
After some digging around in the emacs 25.1 release notes, I noticed that there were some changes to subword-mode
which looked promising. On enabling subword-mode
, I get the correct behavior (only text
is selected).
I can't quite figure out how to fix it, but for reference, the link to the relevant changes in the release notes are here.
Original comment by Mika Vilpas (Bitbucket: sp3ctum, GitHub: sp3ctum):
Sorry, I have downgraded to emacs 24.5.1 on Windows and never gave this any more thought. Nothing stuck out in the changes, but I haven't looked into it extensively.
Original comment by Frank Fischer (Bitbucket: lyro, GitHub: lyro):
Interesting. Any idea what is about to change in Emacs 25?
Original comment by Mika Vilpas (Bitbucket: sp3ctum, GitHub: sp3ctum):
I just downgraded to emacs 24.5.1 and the problem is gone.
Original comment by Mika Vilpas (Bitbucket: sp3ctum, GitHub: sp3ctum):
So this manifests like this. Say the current buffer contains this text, and point be at $, without including the $:
$evil-is-the-best-mode-ever
If I input a *
, I get a search for evil
, instead of evil-is-the-best-mode-ever
. In contrast with what I said in the OP, w
and b
seem to treat the identifier as a single word. However, with point at $
, e
will jump like this:
evi$l-is-the-best-mode-ever
@TheBB thanks for all your input on this -- it helped me at least find a workaround. In case it's useful to others: I added a hook to disable subword-mode in clj/s buffers:
(add-hook 'clojure-mode-hook (lambda () (global-subword-mode -1)))
(or possibly other folks' input now that I look more closely at the comments.)
Note that unlike the comment above mine, which described, enabling subword-mode as giving correct behavior, for me it was the opposite.