In order to change your cursor or caret, what you want to do is:
Open your .emacs file and this line of code:
(setq-default cursor-type 'bar)
And to change the color:
Of course, you can change #ffffff to any hexadecimal color.
Here are few mark-related bindings that can help you:
C-SPC - set mark and activate region (bound to set-mark-command)
C-SPC C-SPC - set mark (activates and then deactivates region)
C-x C-x - bound to exchange-point-and-mark
C-u C-SPC - move to previous mark
Check out the Mark documentation for better understanding of this topic.
You can try setting scroll-preserve-screen-position to always:
(setq scroll-preserve-screen-position 'always)
From the documentation (C-h v scroll-preserve-screen-position):
Controls if scroll commands move point to keep its screen position unchanged.
A value of nil means point does not keep its screen position except
at the scroll margin or window ...
The variable cursor-type controls how the appearance of the cursor, defaulting to t, which uses the cursor specified for the frame (see the docstring for options). If you'd like the cursor to default to a block, you can (setq cursor-type 'box).
However, evil provides a number of different cursors for the different states, which you can adjust to give you a ...
Cursor type can be set for a given buffer (using buffer-local variable cursor-type), as indicated in the answer by @King. (That answer uses setq-default to set the default value for all buffers.)
Or it can be set for a given frame, as frame parameter cursor-type.
You can set it the default cursor type for all frames by adding it to option default-frame-...
There is a new package available on GNU ELPA called scroll-restore that attempts to remedy this problem. There are a handful of different behaviors to choose from, but the way I have configured it for myself (see below) causes the cursor to turn invisible during scrolling commands, and then jump back to its original location when I start typing again.
You need to modify the line-move-visual variable.
You need to set its value to nil if you want the up/down line navigation happen logically (not visually).
When line-move-visual is set to nil
▮his is a very very very very very long line
and it wrapped around here.
This is the next line
After hitting C-n (moving the cursor to the next line) ..
This is a ...
This was a pretty cool question, I learned a lot that I didn't know while trying to figure this out. What I learned was that each window has its own value for point. This is important because it means that the point is not associated with the buffer but instead the actual window. As we've seen this makes a big difference.
What we need to do then is set the ...
(This is too long for a comment, and while not literally an answer, I hope it might help the OP.)
While Drew's answer covers what you literally want, this is probably not what you need. Point in Emacs is never on a character, it is between characters:
Like other positions, point designates a place between two characters
(or before the first character, ...
The answer is here. You probably have a buffer-list open somewhere, and version 24.3 has a bug in tabulated-list-mode which causes the periodic recentering. If you close that buffer-list, behaviour reverts back to normal.
How to stop it permanently
This bug was fixed in Emacs 24.5, so you need to install that, or
something more recent. Currently, 24.5 is ...
You can write a command that will do one thing when at the beginning of the line, and do another when not there. You can then bind it to your key of choice. Example:
(defun message-me ()
(message "At beginning of line")
(message "Not at beginning of line")))
(global-set-key [home] #'message-me)
(Jules Tamagnan's answer identifies the problem, I'll expand on it.)
Your solutions with save-excursion or save-excursion do in fact work! You can see it by checking the value of (point) in that buffer afterwards, e.g.
always returns 42 (...
@Dan's suggestion of using a dispatch command is probably the best approach.
Here is another, that can be useful in some contexts. But it is probably not what you want for the general case you cite, of doing something special at the beginning of any line, anywhere.
You can put a keymap text property on a character in a buffer. Its value is a keymap. Any ...
Bind C-e to a command that puts the cursor one char to the left of the line end.
(defun foo (arg)
(unless (bolp) (backward-char)))
(global-set-key "\C-e" 'foo)
(Although I cannot imagine why you would want to move the cursor there.)
Nope. M-x customize-option cursor shows you the doc string:
Basic face for the cursor color under X. Hide
Currently, only the :background attribute is meaningful; all
other attributes are ignored. The cursor foreground color is
taken from the background color of the underlying text.
Note the last sentence.
Consider filing an enhancement ...
First, you are apparently confusing the mouse pointer with the text cursor (aka cursor). It seems that you mostly talking about the latter, but referring to it as the "cursor".
Second, insertion of a character is always between characters (or before the first or after the last character). This is necessarily so, by definition. Even if it were to behave and ...
The following function moves the cursor to the middle of the current line:
(defun my/move-to-middle ()
(let* ((begin (line-beginning-position))
(middle (/ (+ end begin) 2)))
You can bind this to a key (I used C-c m) using
(global-set-key (kbd "C-c m") 'my/move-to-middle)...
The method that I always use is to set the mark where I want to jump back to, and then when I am done perusing the buffer, I pop the mark using C-u C-SPC. Even when I forget to set the mark before wandering off, I find that popping the mark usually lands me pretty close to where I came from. This is due partly to the fact that some commands (like isearch ...
You can use the char-after or following-char function to know what's the character under the cursor (or after the point).
More on Examing Text Under Point
Remember that point is always between characters, and the cursor normally appears over the character following point.
try to add this code in init.el and restart the daemon:
(defun set-cursor-hook (frame)
frame (list (cons 'cursor-color "DeepSkyBlue"))))
(add-hook 'after-make-frame-functions 'set-cursor-hook)
Using cursor-in-non-selected-windows is the correct approach, but you can set its value locally in the completions buffer instead of globally so it doesn't affect all your other buffers.
The tab completion buffer is running the completions-list-mode major-mode so you can add a hook to completions-list-mode-hook to set the value locally like this:
On a terminal, you can't change the shape of cursor.
From the Emacs manual:
On a text terminal, the cursor’s appearance is controlled by the
terminal, largely out of the control of Emacs. Some terminals offer
two different cursors: a “visible” static cursor, and a “very visible”
blinking cursor. By default, Emacs uses the very visible cursor, and
That's exactly what you get with library cursor-chg.el.
Just turn on minor mode change-cursor-mode, and leave option curchg-change-cursor-on-input-method-flag with its default value of t.
The cursor color when an input method is used is controlled by option curchg-input-method-cursor-color (default value "Orange").
(If you do not also want the cursor ...
You can try quarter-plane-mode (available from GNU ELPA), but beware. Emacs's underlying engine is basically unable to do what you want; it can only place cursor where there is some text), so the package has to do funny things (e.g. it will add spaces as/when needed, IIRC) which will occasionally have side-effects that might surprise you.
You can use the standard Emacs commands C-f and C-b for forward and backward char. It's convenient to learn those, as you can also navigate canditates with C-n and C-p.
You can also use C-l to go up a parent level.
For a tour on Helm, I suggest reading Tuhdo's guide.
If you are okay with returning to the last edit (as opposed to last insertion), you might want to look at the package goto-chg. You can enable it like this:
(global-set-key (kbd "C-.") #'goto-last-change)
(global-set-key (kbd "C-,") #'goto-last-change-reverse)
there must be something wrong with my config, but I don't know what to look for that might be causing it.
So that's your question, in fact: How do I find how my init file caused a problem?
The answer is to use the usual binary search (O(logN)): Recursively bisect your init file until you find what introduces the problem.
You can do this by commenting out ...