Minteh
Minteh

Reputation: 85

How to insert space after cursor?

I am a new user of emacs.
I found some useful options that allows me to insert new line before or after cursor: C-j (before cursor), C-o (after cursor).

I found this very convenient in doing formatting text across lines.
Now, are there methods to insert space after cursor for in-line formatting?
Currently I have to insert space before cursor using Space then C-b multiple times just to return to the original position when doing formatting within one line.

Upvotes: 5

Views: 862

Answers (1)

legoscia
legoscia

Reputation: 41578

I don't think there is such a function, but it is easy to write:

(defun my-insert-space-after-point ()
  (interactive)
  (save-excursion (insert " ")))
(global-set-key (kbd "C-.") 'my-insert-space-after-point)

This binds the function to C-.; adjust to preference.


Another way to do this is to record a macro, save it, and bind it to a key. The steps to do that are described in this answer.

Upvotes: 4

Related Questions