     )
 
   (global-set-key (kbd "C-g") #'magit-status)
+
+  (declare-function with-editor-finish 'with-editor)
+  (declare-function with-editor-cansel 'with-editor)
+  (with-eval-after-load 'with-editor
+    (let ((map with-editor-mode-map))
+      (evil-define-key 'normal map "q!" #'with-editor-cancel)
+      (evil-define-key 'normal map "Q" #'with-editor-finish)
+    ))
+
+  (with-eval-after-load 'git-commit
+    (let ((map git-commit-mode-map))
+      (evil-define-key 'normal map
+        "q!" (lambda () (interactive)
+              (with-editor-cancel nil) (magit-mode-bury-buffer)))
+      (evil-define-key 'normal map
+        "Q" (lambda () (interactive)
+              (with-editor-finish nil) (magit-mode-bury-buffer)))
+      ))
+
   (with-eval-after-load 'magit-popup
     (define-key magit-popup-mode-map [escape] 'magit-popup-quit))
   (with-eval-after-load 'magit

  ;; substitute
  (define-key nmap "-" #'evil-ex-interactive-substitute)
  (define-key vmap "-" #'evil-ex-interactive-substitute)
  (define-key nmap "_" #'(lambda () (interactive) (evil-ex "%s/")))
  (define-key nmap ">" #'evil-ex-repeat-substitute)

  ;; motion

  (define-key mmap (kbd "C-m") nil)
  (define-key mmap [return] #'evil-ret)

  (declare-function dired-find-file 'dired)
  (with-eval-after-load 'dired
    (let ((map dired-mode-map))
      (define-key map [return] #'dired-find-file)
