でも小指が辛いので今のところ viper-mode が必須です。
今まで vim を使ってきたので、素の viper は以下の点で特に辛い。
- gg でバッファの一番上にカーソルが移動しない
- * で検索が開始できない
- C-], C-t でタグジャンプできない
- C-o で前のカーソル位置に戻れない
- backspace で改行が削除できない
- C-wC-w でウィンドウが移動できない
- uの連続でundo連続にならない
- %%% が定義されていて%の対応括弧への移動が遅い
上記だけはカスタマイズしないと少しでも耐えられない。
とりあえず上記を実現。
(defun my-viper-beginning-of-buffer ()
(interactive)
(beginning-of-buffer))
(define-key viper-vi-global-user-map [?g?g] 'my-viper-beginning-of-buffer)
(defun my-viper-star ()
(interactive)
(let ((wd (concat "\\<" (thing-at-point 'symbol) "\\>")))
(setq viper-s-string wd)
(setq viper-s-forward t)
(viper-search wd t 1)))
(define-key viper-vi-global-user-map [?*] 'my-viper-star)
(defun my-viper-jump-tag ()
(interactive)
(setq wd (thing-at-point 'symbol))
(find-tag wd))
(define-key viper-vi-global-user-map [?\C-\]] 'my-viper-jump-tag)
(defun my-viper-jump-tag-next ()
(interactive)
(setq wd (thing-at-point 'symbol))
(find-tag wd 0))
(define-key viper-vi-global-user-map [?\C-:] 'my-viper-jump-tag-next)
(defun my-viper-pop-tag ()
(interactive)
(pop-tag-mark))
(define-key viper-vi-global-user-map [?\C-t] 'my-viper-pop-tag)
(defun my-viper-pop-mark ()
(interactive)
(set-mark-command -1))
(define-key viper-vi-global-user-map [?\C-o] 'my-viper-pop-mark)
(define-key viper-vi-global-user-map [?u] 'undo)
(define-key viper-insert-global-user-map [backspace] 'backward-delete-char-untabify)
(define-key viper-insert-global-user-map [delete] 'delete-char)
(define-key viper-emacs-global-user-map "\C-w\C-w" 'other-window)
(define-key viper-vi-global-user-map "\C-w\C-w" 'other-window)
(define-key viper-emacs-global-user-map "\C-w\C-o" 'delete-other-windows)
(define-key viper-vi-global-user-map "\C-w\C-o" 'delete-other-windows)
;; dired を少しだけ vi 風に
(define-key viper-dired-modifier-map "j" 'dired-next-line)
(define-key viper-dired-modifier-map "k" 'dired-previous-line)
(define-key viper-dired-modifier-map "/" 'dired-goto-file)
(define-key viper-dired-modifier-map "l" '(lambda () (interactive) (dired-next-line 10)))
(define-key viper-dired-modifier-map "h" '(lambda () (interactive) (dired-previous-line 10)))
;;%%% の viper-toggle-parse-sexp-ignore-comments を止める
(viper-set-parsing-style-toggling-macro t)