Questions tagged [insert]
72 questions
20
votes
5 answers
Result of arithmetic evaluation in buffer, not echo area
Windows 10, Emacs 25.1
I want to do some arithmetic operation I do this:
The result is in the echo area, but I want the result to be in cursor place in the buffer. Something like this:
How do I do this?

user8542613
- 643
- 6
- 16
18
votes
1 answer
How do I insert text with a specific face?
I have a face, created this way:
(defface test-face
'((t . (:height 2.0)))
"A face for testing.")
I'd like to insert some text with that face. But these ways insert the text without the face:
(insert (propertize "text to insert" 'face…

zck
- 8,984
- 2
- 31
- 65
7
votes
1 answer
Insert line above/below
I have a couple of functions for inserting blank lines above and below the current line:
(defun insert-line-below ()
(interactive)
(move-end-of-line nil)
(open-line 1))
(defun insert-line-above ()
(interactive)
(move-beginning-of-line…

Simon
- 411
- 6
- 15
7
votes
1 answer
How to insert a new same-level headline after current one?
Suppose I have an org-mode buffer that contains the outline shown below, and that point is at the position indicated by the ▮ character.
* foo
** bar
*** baz
- eenie
- yabba
- dabba▮
- doo
- meenie
- minie
* frobozz
**…

kjo
- 3,145
- 14
- 42
6
votes
1 answer
Mimic self-insert-command with insert/insert-char?
Due to various/extensive remappings I insert symbols with Control+key, for example Ctrl+9 inserts a left parenthesis (. This works fine with the remappings and the insert/insert-commands, however, modes such as smartparens do not catch this. In my…
user6729
6
votes
2 answers
Insert multiple minus ('-') characters using the universal argument (C-u)
I was manually creating a table in my source code's multiline comments
and inserting horizontal separators using - and =. E.g. C-u C-u C-u = as expected and inserts 64 =s at the point. But - is used to provide negative arguments and does not work in…

loonatick
- 217
- 1
- 5
6
votes
1 answer
Spacemacs : insert single character in normal mode
I am using Spacemacs in Vim mode, and I would like to be able to insert a single character while remaining in normal mode, as described here for Vim.
For example, typing SPC i k in normal mode would insert k where the cursor stands, while SPC a k…

BenzoX
- 83
- 3
6
votes
2 answers
Key bound to string does not handle some chars in string correctly
(I ask this question after reading this one.)
The form
(global-set-key (kbd "M-e") "e")
is, as far as I can tell, equivalent to
(global-set-key (kbd "M-e") (lambda () (interactive) (insert "e")))
However, after evaluating
(global-set-key (kbd…

T. Verron
- 4,233
- 1
- 22
- 55
6
votes
1 answer
Insert into specific buffer (not the active buffer)?
Is there any way to insert text into a buffer that isn't the active buffer with Elisp?
Perhaps there is an equivalent to with-temp-buffer that takes a specific, existing buffer as an argument?

JCC
- 989
- 5
- 15
6
votes
3 answers
How to insert a specific number of newlines in org-mode
Inside org-mode, RETURN is bound to (org-return &optional INDENT). This command apparently ignores C-u numeric prefixes and so if you want to enter 10 newlines, you can't just type C-u 1 0 RET and have it work. You can do C-u 1 0 M-x newline and get…

William Everett
- 195
- 7
6
votes
2 answers
How to insert invalid UTF-8 sequence
In order to test that some code handles an invalid UTF-8 sequence properly, I need to insert an invalid UTF-8 sequence into an existing text file. However, my attempts to do so result in a valid UTF-8 sequence, not an invalid one.
The byte 0xff is…

Wayne Conrad
- 163
- 7
5
votes
1 answer
How to insert a formatted string into a specific buffer?
I am looking for a way to insert a formatted text into a specific buffer (not the active buffer).
As it seems to me, the only way to do so is to use a snippet as shown below:
(insert (propertize (format-time-string "%H:%M:%S")
…

myTerminal
- 417
- 1
- 5
- 15
5
votes
2 answers
Define an emacs function to take arguments in the same way as something like M-x goto-line
I want to write an emacs function for debug purposes in c++ code. Basically I'm fed up typing the following:
std::cout << "variable is: " << variable << std::endl;
Instead I want to define an emacs function called say "td" for temp debug such that…

Joey O
- 135
- 3
5
votes
2 answers
Insert a string from eval-expression without the quotes
I want to use C-u M-:, then (format-time-string "%m/%d/%Y") to insert a customized date string. But it is inserted into the current buffer with double quotes.
Any trick to remove these quotes?

David S.
- 395
- 2
- 13
4
votes
2 answers
How to insert character or word N times in a buffer or file?
Just curious to know how to do this, since i already know in other languages (bash, etc).
I know how to insert a character in elisp, just not sure on how to do it when it's done nth time (in succession) in elisp.
Here an example:
Basically,…

Nordine Lotfi
- 345
- 2
- 13