Function: set-goal-column

set-goal-column is an interactive and byte-compiled function defined in simple.el.gz.

Signature

(set-goal-column ARG)

Documentation

Set the current horizontal position as a goal column.

This goal column will affect the C-n (next-line) and C-p (previous-line) commands, as well as the C-v (scroll-up-command) and M-v (scroll-down-command) commands.

Those commands will move to this position in the line moved to rather than trying to keep the same horizontal position.

With a non-nil argument ARG, clears out the goal column so that these commands resume normal motion.

The goal column is stored in the variable goal-column. This is a buffer-local setting.

View in manual

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/simple.el.gz
(defun set-goal-column (arg)
  "Set the current horizontal position as a goal column.
This goal column will affect the \\[next-line] and \\[previous-line] commands,
as well as the \\[scroll-up-command] and \\[scroll-down-command] commands.

Those commands will move to this position in the line moved to
rather than trying to keep the same horizontal position.

With a non-nil argument ARG, clears out the goal column so that
these commands resume normal motion.

The goal column is stored in the variable `goal-column'.  This is
a buffer-local setting."
  (interactive "P")
  (if arg
      (progn
        (setq goal-column nil)
        (message "No goal column"))
    (setq goal-column (current-column))
    (message "Goal column %d %s"
             goal-column
	     (substitute-command-keys
	      "(use \\[set-goal-column] with an arg to unset it)")))
  nil)