(defun c-switch-to-header () "Switch to or from the header of a C source file." (interactive) (when (string-match "\\([a-zA-Z0-9\-\_\/]+\\)\\.\\([ch]\\)" (buffer-name)) (if (string= "c" (match-string 2 (buffer-name))) (setq ext ".h") (setq ext ".c")) (find-file (concat (match-string 1 (buffer-name)) ext)))) (global-set-key [f8] 'c-switch-to-header)