72

I know how to go to a variable definition in Emacs using semantic-mode. It works well in a single file (I think it doesn't work if the definition is in another file). Using C-c , j, I can go to the definition of the variable, but, how do I jump back to the previous line? Currently I use display Symref C-c , g, and select the displayed symref.

Is there any straight method?

tshepang
  • 12,111
  • 21
  • 91
  • 136
swdev
  • 4,997
  • 8
  • 64
  • 106

1 Answers1

125

Use:

C-u C-space or C-u C-@

If you want to navigate back between buffers, you can use:

C-x C-space or C-x C-@

This makes Emacs jump to the mark (and set the mark from position popped off the local mark ring) which has usually been set by a previous jump command.

Thomas
  • 17,016
  • 4
  • 46
  • 70
  • nice Thomas! That's working as expected :). Hm, being not able to go to another buffer, is not quite a problem. because Semantic-Mode can not also open definition to another file/buffer. Or, can it? – swdev Feb 07 '11 at 09:43
  • I don't know about semantic-mode, but in any case `C-u C-@` would not take you back to the original buffer. – Thomas Feb 07 '11 at 13:18
  • @Thomas It's been a couple of months since you asked this so it might be a new feature, but yes, semantic can find definitions in other buffers/files and jump to them. When that happens just go back to previous buffer `C-x b RET`, and the point should still be where you left it. – Malabarba Apr 26 '12 at 13:58
  • 12
    By the way, `C-x C-space` (instead of C-u) jumps to the global mark, which works even across buffers. – Malabarba Apr 26 '12 at 14:05
  • `C-space` is bound to `set-mark-command`. When invoked with prefix argument, i.e., `C-u C-space`, this function will "jump to the mark, and set the mark from position popped off the local mark ring (this does not affect the global mark ring). Use [`C-x C-space`] to jump to a mark popped off the global mark ring (see `pop-global-mark`)." This and more information can be found in the documentation for `set-mark-command` which you get to by typing `C-h k C-space`. – Thomas Sep 28 '15 at 21:52
  • 2
    @nephewtom As always, the way you find out which command/function is executed by a key chord is to issue: C-h k. So for example: C-h k C-h k will tell you that C-h k is bound to 'describe-key', which is exactly what you want. – Vlatko Šurlan Apr 27 '16 at 20:01
  • Sorry, I do not remember when I asked that. Of course I know C-h k, I use it quite often. But since C-u runs _universal-argument_, that might be the reason for my question. – nephewtom Apr 28 '16 at 08:38
  • By the way, I already mentioned `C-h k` in my comment from last September. – Thomas Apr 28 '16 at 12:51
  • How can I press `C-x C-@` should it be `ctrl+shift+2` ? – alper May 14 '21 at 22:31
  • You first press `CTRL` and `x`, and then you press `CTRL` and `@`. You don't have to release `CTRL` for that. Where exactly the `@` sign is on your keyboard depends on your locale / keyboard layout, but note that you can also type `C-x C-space`. – Thomas May 16 '21 at 20:58