Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to insert space after cursor?

Tags:

emacs

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.

like image 629
Minteh Avatar asked Sep 30 '22 08:09

Minteh


1 Answers

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.

like image 91
legoscia Avatar answered Nov 01 '22 10:11

legoscia