What is the short-cut key to jump to declaration in Emacs?

前端 未结 4 1206
误落风尘
误落风尘 2021-01-31 03:18

In visual studio it \'s easier to push F12 button to jump to a declaration of a function or variable when editing C/C++ code.

Is there a short-cut key in emacs to do th

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-31 04:20

    Well, it's a bit more involved than that.

    By default, Emacs doesn't "know" about function declarations for C or C++ code. First, obtain Exuberant Ctags. Then, use command etags (ctags for Emacs) on your source code. A file named TAGS will be generated.

    Then, while editing your source code, when you want to jump to a declaration, press M-. (meta and dot, or alt and dot on modern keyboards). At first, Emacs will ask you for location of your tags file. Point it to the one you generated and afterwards navigation will be automatic.

    I'd suggest reading Emacswiki article about tags for a better understanding of this functionality.

    The newest version of Emacs (23.2) comes with CEDET integrated, which has more advanced features for C and C++ navigation, but it can be a bit difficult to set up right, so read more about it if you're interested.

提交回复
热议问题