quickly switching between header and implementation

A trivial yet useful trick: when coding C/C++, you often jump from header file (.h, .hh etc.) to implementation file (.c, .cc etc.). Emacs has built-in support for this, using ff-find-other-file. We can add a key binding to .emacs:
(add-hook 'c-mode-common-hook
(lambda()
(local-set-key (kbd "C-c o") 'ff-find-other-file)))

Now, we can quickly switch between myfile.cc and myfile.h with C-c o. Note the use of the c-mode-common-hook, so it will work for both C and C++.

No comments:

Post a Comment

Followers

Popular Posts