 ;; general key bindings
 
 ;; commenting
-(global-set-key (kbd "C-c c")     'comment-region)
-(global-set-key (kbd "C-c u")     'uncomment-region)
-(global-set-key (kbd "C-c SPC")   'comment-dwim)
-(global-set-key (kbd "C-c C-SPC") 'comment-dwim)
+(bind-key "C-c c"     'comment-region)
+(bind-key "C-c u"     'uncomment-region)
+(bind-key "C-c SPC"   'comment-dwim)
+(bind-key "C-c C-SPC" 'comment-dwim)
 
 ;; error
-(global-set-key (kbd "C-c n") 'next-error)
-(global-set-key (kbd "C-c p") 'previous-error)
-(global-set-key (kbd "M-t")   'find-tag)
+(bind-key "C-c n" 'next-error)
+(bind-key "C-c p" 'previous-error)
+(bind-key "M-t"   'find-tag)
 
 ;; eval shortcut
-(global-set-key (kbd "C-S-M-x")   'eval-buffer)
-
-
-(global-set-key (kbd "C-f")    'forward-word)
-(global-set-key (kbd "C-b")    'backward-word)
-(global-set-key (kbd "M-f")    'forward-sentence)
-(global-set-key (kbd "M-b")    'backward-sentence)
-(global-set-key (kbd "<home>") 'beginning-of-buffer)
-(global-set-key (kbd "<end>")  'end-of-buffer)
+(bind-key "C-S-M-x"   'eval-buffer)
+
+
+(bind-key "C-f"    'forward-word)
+(bind-key "C-b"    'backward-word)
+(bind-key "M-f"    'forward-sentence)
+(bind-key "M-b"    'backward-sentence)
+(bind-key "<home>" 'beginning-of-buffer)
+(bind-key "<end>"  'end-of-buffer)
 
 ;; allowed key components
-(use-package free-keys)
-(setq free-keys-keys
-      (concat "abcdefghijklmnopqrstuvwxyz"
-              "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-              "1234567890"
-              "!@#$%^&*()-=[]{};'\\:\"|,./<>?`~_+"
-              ))
+(use-package free-keys
+  :config
+  (setq free-keys-keys
+        (concat "abcdefghijklmnopqrstuvwxyz"
+                "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                "1234567890"
+                "!@#$%^&*()-=[]{};'\\:\"|,./<>?`~_+"
+                )))
 ;; unset unwanted default keys
 (cl-loop for key in `(
                       (,(kbd "C-x C-z") suspend-frame)

(use-package phi-search-mc
  :ensure t
  :defer t
  :config
  (define-key phi-search-default-map (kbd "<C-down>") 'phi-search-mc/mark-next)
  (define-key phi-search-default-map (kbd "<C-up>")   'phi-search-mc/mark-previous)
  (define-key phi-search-default-map (kbd "C-c C-k")  'phi-search-mc/mark-all))

;; undo tree
(use-package undo-tree
  :ensure t
  :diminish undo-tree
  :commands (undo-tree-undo undo-tree-redo)
  :init
  (global-undo-tree-mode)
  :config
  (setq undo-tree-visualizer-timestamps t)
  (define-key undo-tree-map (kbd "C-x u") 'undo-tree-visualize)
  ;; undo
  (global-set-key (kbd "C-z") 'undo-tree-undo)
  (global-set-key (kbd "M-z") 'undo-tree-redo))


;; copy end of line, like C-k

    (if (eq last-command 'copy-to-kill)
        (append-next-kill))
    (kill-ring-save (mark) (point))))
(bind-key "M-k" 'copy-line)

;; move to beginning of text on line
(defun smart-beginning-of-line ()
