Put this in a file and load it (load means execute):
(defun vi-goto-line (arg)
(interactive "sLine:")
(message arg)
(if (string= "$" arg)
(end-of-buffer)
(goto-line (string-to-int arg))
)
)
(global-set-key (kbd "M-:") 'vi-goto-line)
To load it you can use M-xload-file
and then enter interactively the path to the file.
Keep in mind that the key combo M-: (which is the same as ESC:) already has a meaning in Emacs, so this now gets cloaked.
Of course you also can load the file from your .emacs
by putting (load-file "/path/to/my/file")
into the .emacs
or put these lines directly into your .emacs
file (or any other configuration file which gets loaded)