5

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.

Minteh
  • 75
  • 1
  • 5
  • 1
    @legoscia answered your question. Remember too that you can easily do this kind of thing using a keyboard macro. (Of course, if you want to do it a lot then you want to define a command for it once and for all - e.g., as legoscia has shown.) – Drew Jul 16 '14 at 15:03
  • @Drew Thanks for the tips. One question with macro: is there a way to define, store, and invoke macro that could persists after re-opening emacs? – Minteh Jul 16 '14 at 15:27
  • @Minteh, yes, I described how to do it [here](http://stackoverflow.com/a/19640686/113848). – legoscia Jul 16 '14 at 15:32
  • 2
    See the Emacs manual, node `Save Keyboard Macro` - in particular, command `insert-kbd-macro`. – Drew Jul 16 '14 at 15:32
  • @legoscia Thanks. Well-edited steps. – Minteh Jul 16 '14 at 16:21
  • @Drew Thanks. great reference. – Minteh Jul 16 '14 at 16:25

1 Answers1

4

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.

legoscia
  • 39,593
  • 22
  • 116
  • 167