Reputation: 21
I'm currently using Emacs 24.0.91.1 and every once in a while, the cursor behavior changes when I am in c-mode (with auto-fill-mode enabled).
What I want is for the cursor to stay on the same column when I move one line up/down. However, every once in a while, it jumps to position 0, which I find highly annoying. Any tips on how to disable this?
Upvotes: 2
Views: 490
Reputation: 8308
I found myself in this same situation when jamming a lot of keys into
my emacs windows without being too careful. However, I noticed that it would keep reverting my cursor to a particular column, not necessarily column 0. Like the OP, I originally resorted to
killing and reopening the buffer to clear this behavior. However, after
searching, I realized that I must have accidentally typed C-x C-n when
trying to rapidly jam some commands, resulting in accidentally
invoking set-goal-column
.
C-x C-n
Use the current column of point as the semipermanent goal column for C-n and C-p (set-goal-column). When a semipermanent goal column is in effect, those commands always try to move to this column, or as close as possible to it, after moving vertically. The goal column remains in effect until canceled.
When invoking this command, I get the following output in emacs’s *Messages*
buffer:
Goal column 16 (use C-x C-n with an arg to unset it)
To supply C-x C-n with an argument and remove this effect, you may
supply the argument using a “numeric prefix argument”. For example,
C-0 C-x C-n (supplying a numeric prefix argument of 0
) clears the
semipermanent goal column.
Upvotes: 5