How to determine key binding inside a marked area

I have an idea to better mark regions in emacs.

  • I press C-SPC to start.

  • I use vi style key to expand selection. such as

"j" : line down "k": line up 

instead of using the arrow keys or Cn, Cp, single char is easier to press

  • When making a selection, I select a key to do something, also use vi style key

    "c": deactivated area, copy area. "d" delete area Comment area "#" "space" just walks away without doing anything

I know that I can use "Mw", "Mk" or something like that, but I think the vi style key is an easier way to get the job done.

I am looking everywhere but there is no elip package that can do such a thing.

Can someone help me write some functions for this? Or give me some tips.

I found a good way to do this, shared a solution:

(

 defvar active-region-mode-map (let ((map (make-sparse-keymap))) map) ) (define-minor-mode active-region-mode "Active Region minor mode." :init-value nil :lighter " Region" :keymap active-region-mode-map :group 'active-region ) (defun active-region-on () (active-region-mode 1)) (defun active-region-off () (active-region-mode -1)) (add-hook 'activate-mark-hook 'active-region-on) (add-hook 'deactivate-mark-hook 'active-region-off) 

Now, enjoy it, the "active-region-mode-map" map is right for you. For instance:

 (define-key active-region-mode-map (kbd "j") 'next-line) 
+4
source share
1 answer

You can watch viper-mode .

0
source

Source: https://habr.com/ru/post/1347929/


All Articles