(require 'switch-file) (setq switch-path '("../include/" "../src/" "./")) ; will search c cpp and h in ./ , ../include and ../src (defun switch-c () (global-set-key [f1] 'switch-c-to-h) ) (add-hook 'c-mode-hook 'switch-c) (defun switch-cpp () (global-set-key [f1] 'switch-cc-to-h) ) (add-hook 'c++-mode-hook 'switch-cpp)