Emacs C++, opening corresponding header file


There’s ff-find-other-file.

You can bind this to your own key using something like:

(global-set-key (kbd "C-x C-o") 'ff-find-other-file)

But of course you’ll need to pick a key that doesn’t already have something useful bound to it 🙂


Check the excellent Emacs-fu article Quickly switching between header and implementation

In case the blog post has gone, here is copy of the solution:

(add-hook 'c-mode-common-hook
    (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++.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s