Monday, November 05, 2007

Emacs goto-column function

Found this at

Put it in your .emacs file.

(defun goto-column-number (number)
"Untabify, and go to a column number within the current line (1 is beginning
of the line)."
(interactive "nColumn number ( - 1 == C) ? ")
(untabify (point-min) (point-max))
(while (> number 1)
(if (eolp)
(insert ? )
(setq number (1- number))))

To use it in emacs, use "Esc-X goto-column-number", enter, and type column number of the current line.


Unknown said...

Nice thing. Tnx. :)

Unknown said...

Thanks! It's so useful!

OtherMichael said...

You can also add a wrapper to the move-to-column function:

;; move to column in current line
(defun repos (position)
(interactive "nPosition: ")
(move-to-column position)