0
votes

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)?
1

1 Answers

2
votes

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)