0

I'm new to Emacs. I have Emacs 24.3.1 with evil mode installed. I'm trying to bind gw as a prefix to the various evil-window functions. For example, I would like gwl to focus the window to the right, and gwh the window to the left. Of course, this is done in vim like so: nnoremap gw <c-w>.

In .emacs.d/config/init-bindings.el, I added:

  (define-key evil-normal-state-map (kbd "g w h") 'evil-window-left)
  (define-key evil-normal-state-map (kbd "g w j") 'evil-window-down)
  (define-key evil-normal-state-map (kbd "g w k") 'evil-window-up)
  (define-key evil-normal-state-map (kbd "g w l") 'evil-window-right)
  (define-key evil-normal-state-map (kbd "g w v") 'evil-window-vnew)

And emacs reports this error:

error: Key sequence g w h starts with non-prefix key g w
  • How do I make gw a prefix key?
  • Is there any reason this might be a bad idea (conflicts with important emacs defaults)?
Justin M. Keyes
  • 6,679
  • 3
  • 33
  • 60

1 Answers1

2

Reading your question (and not your answer), I managed to map gwh to evil-window-left doing the following:

  • is gw bound to an action ? Asking the help with C-h-k gw told me yes.
  • gz isn't, so using gzh worked out of the box:

    (define-key evil-normal-state-map (kbd "gzh") 'evil-window-left)
    
  • so un-mapping gw allowed to use gwh:

    (define-key evil-normal-state-map "gw" nil)
    (define-key evil-normal-state-map (kbd "gwh") 'evil-window-left)
    

ps: you still can fill paragraphs with M-q

pps: I myself like windmove with Super key more :)

    (require 'windmove)
    (windmove-default-keybindings 'super)
Ehvince
  • 17,274
  • 7
  • 58
  • 79
  • Thanks, I think the key piece of information I was missing is that `(define-key evil-normal-state-map "gw" nil)` is the way to `unmap` in evil... I guess. Also, `C-h-k gw` waits indefinitely for a terminating key (pressing enter makes it read the input as `gw`). Any idea how to get it to accept `gw` ? – Justin M. Keyes Nov 29 '13 at 23:04