Emacs goto line

08 Jan 2010
Posted by stylesen

I was reading through this post and thought I can share my recipe for the same problem. In the past (3 years back) I had the same difficulty of instructing emacs to goto a line. Each time I want to do that I need to "M-x" and type "goto-line" (tab completion is there). But this is annoying since I may need to do this 'n' number of times while writing code. I wanted a good short cut, I chose 'C-l' for this and hence came up with the following lines in my .emacs file which am so used to that in any system as soon as I open and read code in emacs, I keep pressing 'C-l' :)

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

Though I learnt from Senthilkumaran's blog post comments that the default that comes along in emacs is 'M-g-g' (which works in Debian and Ubuntu boxes), but I somewhat feel it will take time for me to make my fingers learn this deafult.

Having said that, I ve put my .emacs file in the attachments of this post, which may help someone.

dotemacs_stylesen.txt2.93 KB

Thanks for the post! M-g-g

Thanks for the post! M-g-g works pretty.

But what about recenter? :O

Man, oh man. I would never be able to get used to C-l being goto-line. For me, C-l means "recenter-top-bottom", (default on fresh installs of Emacs). If I would ever rebind goto-line, it might be to M-l ("downcase-word") in that case, which I don't use as often.
For me, M-g-g is awesome. :-)

I do not user recenter!

Since I don't use 'recenter-top-bottom' I dont feel I miss anything here by binding 'C-l' to goto line!

Thanks a lot. ;)

Thanks a lot. ;)