Thursday, August 02, 2007

Emacs: goto

How to go to a specified line in Emacs. Though i had this doubt for a very long time i never searched for it. Today got the answer when i was searching for some GDB stuffs. Anyway here it is. Add the following two lines in .emacs and restart emacs.

(global-unset-key [?\M-1])
(global-set-key [?\M-l] 'goto-line)

Now pressing Alt+1 or Esc+1 will prompt for the line to jump. Don't know whether there is anyother way but this is the first way i found.


xurizaemon said...

M+g (or M+g,g on Aquamacs) is the default keybinding for this, I think.

senthilkumaran said...

Yeah, even those two lines are not necessary i think. Emacs has default key binding for this, but i found that to be M+l.

David said...

On the xemacs I'm using (OpenSUSE 11.1), it's M-?. I found that by typing M-x goto-line.

vamshi said...

its M-g g in mine

Senthil Kumaran said...

M-g g & M-g M-g are available starting from Emacs 23.2. Older versions of GNU Emacs we will have to use the "M-x goto-line. Or map a key binding for it,

;; Goto-line short-cut key
(global-set-key "\C-l" 'goto-line)