Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to define keybinding inside a marked region
    primarykey
    data
    text
    <p>I have a idea to mark regions in emacs easier.</p> <ol> <li><p>I press C-SPC to start.</p></li> <li><p>I use a vi style key to extend selection. such as </p></li> </ol> <blockquote> <pre><code>"j" : line down "k": line up </code></pre> </blockquote> <p>instead of using arrow key or C-n, C-p, a singe char is easier to press</p> <ol> <li><p>When finish selecting, I choose a key to do some thing, also use a vi style key</p> <p>"c": deactive region, copy region. "d" delete region "#" comment region "space" just leaving without do anything</p></li> </ol> <p>I know I can use "M-w" "M-k" or something to do it, but I think vi style key is a easier way to do the job.</p> <p>I search everywhere, but there is no elip package can do such thing.</p> <p>Can someone help me to write some functions to do it? Or give me some suggestions. </p> <p>I found a nice way to do it, share the solution:</p> <p>(</p> <pre><code>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) </code></pre> <p>Now, enjoy it, "active-region-mode-map" map keybinding you like. For example:</p> <pre><code>(define-key active-region-mode-map (kbd "j") 'next-line) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload