I use Emacs mostly for writing text not code. This involves a great deal of selecting, deleting and editing, as one would expect. By default if I move forward by a word in Emacs, Emacs ignores basic punctuation such as . , ; ? ! ' ". This is especially problematic for me when I want to copy or delete text because it involves using both M-f and then C-f. What I would like is for Emacs to move forward to the empty space AFTER a punctuation mark, so that the punctuation mark after a word becomes part of the selection. If one moves forward by sentences, Emacs does this naturally, but not when one moves by words, and by implication by phrases.
For example, in the sentence,
Bob went to the store, in a joyful, happy mood.
If I wanted to delete the words "to the store," (including the comma) I would like to simply use the mark and press M-f 3 times without also having to then press C-f.
I have tried some solutions but none of them really worked for me, including,
- evil-mode (I like Vim's behaviour when it comes to moving by words, but do not wish to change my whole workflow to evil)
- forward-same-syntax (movements are too refined)
- the package syntax-subword (changes the Emacs default too radically)
Please note that my default file mode is org-mode, not text-mode.
subword.el
built-in library? You can define your own functions and assign them thesubword-forward-function
andsubword-backward-function
variables. I wrote my own forward/backward function several years ago, and I've modified it since then .... here is a link to the old version .... stackoverflow.com/questions/18675201/… See also the functionforward-symbol
-- there are other functions insubr.el
for movement that you may wish to have a look at.