(define-key viper-vi-basic-map "Q" 'toggle-kbd-macro-recording-on) (define-key viper-vi-basic-map "q" 'call-last-kbd-macro) (define-key viper-vi-basic-map "\C-k" 'move-text-up) (define-key viper-vi-basic-map "\C-j" 'move-text-down) (define-key viper-vi-global-user-map "C" 'comment-dwim-line) (define-key viper-vi-basic-map [f5] 'whitespace-mode) (define-key viper-vi-basic-map [f6] 'toggle-linum) (define-key viper-vi-basic-map [f7] 'toggle-minimap) (define-key viper-vi-basic-map [f11] 'dbl:insert-date) (define-key viper-vi-basic-map [f12] 'whizzytex-mode) ;; ;; Functions ;; (defvar minimap-is-on 0) (defun toggle-minimap () "toggle minimap on/off" (interactive) (if (= minimap-is-on 1) (progn (minimap-kill) (setq minimap-is-on 0)) (progn (minimap-create) (setq minimap-is-on 1)))) (defun toggle-kbd-macro-recording-on () "One-key keyboard macros: turn recording on." (interactive) (define-key viper-vi-basic-map (this-command-keys) 'toggle-kbd-macro-recording-off) (start-kbd-macro nil)) (defun toggle-kbd-macro-recording-off () "One-key keyboard macros: turn recording off." (interactive) (define-key viper-vi-basic-map (this-command-keys) 'toggle-kbd-macro-recording-on) (end-kbd-macro)) (defun move-text-internal (arg) (cond ((and mark-active transient-mark-mode) (if (> (point) (mark)) (exchange-point-and-mark)) (let ((column (current-column)) (text (delete-and-extract-region (point) (mark)))) (forward-line arg) (move-to-column column t) (set-mark (point)) (insert text) (exchange-point-and-mark) (setq deactivate-mark nil))) (t (beginning-of-line) (when (or (> arg 0) (not (bobp))) (forward-line) (when (or (< arg 0) (not (eobp))) (transpose-lines arg)) (forward-line -1))))) (defun move-text-down (arg) "Move region (transient-mark-mode active) or current line arg lines down." (interactive "*p") (move-text-internal arg)) (defun move-text-up (arg) "Move region (transient-mark-mode active) or current line arg lines up." (interactive "*p") (move-text-internal (- arg))) ;; Original idea from ;; http://www.opensubscriber.com/message/emacs-devel@gnu.org/10971693.html (defun comment-dwim-line (&optional arg) "Replacement for the comment-dwim command. If no region is selected and current line is not blank and we are not at the end of the line, then comment current line. Replaces default behaviour of comment-dwim, when it inserts comment at the end of the line." (interactive "*P") (comment-normalize-vars) (if (and (not (region-active-p)) (not (looking-at "[ \t]*$"))) (comment-or-uncomment-region (line-beginning-position) (line-end-position)) (comment-dwim arg)))