Emacs C++, opening corresponding header file

2019-03-11 00:15发布

I am new to emacs and I was wondering

  • if there is a shortcut to switch between header/source and the corresponding source/header file

  • if there is a reference card like the general emacs ref card

Thanks !

标签: c++ c emacs
3条回答
我欲成王,谁敢阻挡
2楼-- · 2019-03-11 01:08

I'm using eassist package from CEDET contrib, and it has eassist-switch-h-cpp function to do this taks

查看更多
别忘想泡老子
3楼-- · 2019-03-11 01:13

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
  (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++.

查看更多
We Are One
4楼-- · 2019-03-11 01:15

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 :)

查看更多
登录 后发表回答