   (define-key function-key-map "\e[6;5~" [C-next])
   (define-key function-key-map "\e[1;5~" [C-home])
   (define-key function-key-map "\e[4;5~" [C-end])
+  (define-key function-key-map "\e[4;5~" [C-end])
+  (define-key function-key-map (kbd "C-^") [C-return])
 
   ;; Cygwin's mintty
   ;; (define-key function-key-map "\e[1;5I" [C-tab])

  (load "osc52.el")
  (osc52-set-cut-function))

; Dynamic abbrev should copy the word it finds verbatim
(setq dabbrev-case-replace nil)

(global-set-key "\C-z" 'undo)

; Extra copy-paste
(global-set-key (kbd "C-S-v") 'yank)
(global-set-key (kbd "C-S-c") 'kill-ring-save)

;; C-space may not be available in some window managers, so 
;; use Alt-Space for marking as well. 
(global-set-key (kbd "M-SPC") 'set-mark-command)

(when (fboundp 'ido-mode)
  (ido-mode 'buffers))

; Ignore accidental hiting of insert
(global-unset-key [insert])
(global-unset-key [insertchar])

; Remove the binding for keyboard-escape-quit. It is way too easy to trigger
; it via autorepeat of the escape key.
(global-unset-key "\e\e\e")

(global-unset-key "\C-x3")
(global-set-key "\C-x3" 'my-2-window-split)

; Custom bindings through a prefix key
(let* ((my-prefix1 ?\M-q)
       (old-prefix-action (lookup-key (current-global-map) (vector my-prefix1))) 
       (f (lambda (key action)
	    (global-set-key (vector my-prefix1 key) action)
	    )))
  (when old-prefix-action
    (global-unset-key (vector my-prefix1))
    (funcall f ?q old-prefix-action))
    
  (funcall f ?c 'compile)
  (funcall f ?e 'eshell)
  (funcall f ?g 'grep)
  (funcall f ?r 'rgrep)

  ;; C-x k <enter> is too long for buffer kill, so make f3 k as shortcut.
  (funcall f ?k (lambda () (interactive) (kill-buffer nil)))

  (funcall f ?t (lambda () (interactive) (my-run-terminal "term")))
  (funcall f ?1 (lambda () (interactive) (my-run-shell "shell_1")))
  (funcall f ?2 (lambda () (interactive) (my-run-shell "shell_2")))
  (funcall f ?3 (lambda () (interactive) (my-run-shell "shell_3")))
  (funcall f ?4 (lambda () (interactive) (my-run-shell "shell_4")))
  (funcall f ?5 (lambda () (interactive) (my-run-shell "shell_5")))
  (funcall f ?6 (lambda () (interactive) (my-run-shell "shell_6")))
  (funcall f 'insert 'overwrite-mode)
  (when (fboundp 'ispell-region)
    (funcall f ?i 'ispell-region))
  (funcall f ?f 'my-toggle-fullscreen)
)

; Bindings for the debugger
(let ((dbg-prefix 'f5))

(setq undo-limit 2000000)
(setq undo-strong-limit (* undo-limit 2))

; navigating by visual lines
(global-visual-line-mode t)
(setq visual-line-fringe-indicators '(left-curly-arrow right-curly-arrow))

; clipboard
(defun copy-to-x (start end)
