I was not satisfied with the behavior of standard C-arrow
and C-S-arrow
, so I wrote this functions to replace standard ones.
(setq separators-regexp "[\-'\"();:,.\\/?!@#%&*+=]")
(defun forward-to-separator()
"Move to the next separator like in the every NORMAL editor"
(interactive)
(let ((my-pos (re-search-forward separators-regexp)))
(goto-char my-pos)))
(defun backward-to-separator()
"Move to the previous separator like in the every NORMAL editor"
(interactive)
(let ((my-pos (re-search-backward separators-regexp)))
(goto-char my-pos)))
(global-set-key (kbd "C-<right>") 'forward-to-separator)
(global-set-key (kbd "C-<left>") 'backward-to-separator)
But now I am facing a problem with shift selection: it actually just not working at all.
So my question is: how can I select text using my new functions and shift key(C-S-arrow
)?
My final code is here: https://gist.github.com/FirstTimeInForever/8303ac1918c81365991d7acf7a926bd8
I added C-<backspace>
support and changed my regex. Now I can move cursor like in sublime text!