Questions tagged [text-editing]
Questions about editing or manipulating text inside of Emacs.
224
questions
0
votes
1
answer
35
views
How to convert string to ascii or unicode hex?
I somewhat routinely need to convert an arbitrarily long string to hex, usually encoded as ascii or unicode.
Is there a way to quickly and easily do this using vanilla Emacs? If not, is there a go to ...
1
vote
0
answers
47
views
How to open file with it being editable but not writeable?
I teach, and I like to use real files as examples in class. I want to be able to edit the buffer to show student things, but I don't want to risk accidentally writing the changes on the file.
What I ...
1
vote
1
answer
29
views
Masking text / replacing a region with one character
I often find I want to "mask" text in a text file, such as overwriting a secret value in an example file.
For example, I want to change
SECRET_PASSWORD=123abc456
to
SECRET_PASSWORD=XXXXXXXXX....
2
votes
1
answer
181
views
How can I insert the backslash character ( \ ) before quotation marks (" ") in Emacs?
I am running Emacs and writing on the scratch-buffer. This is my config file.
After executing describe-mode, this is the list of minor modes running:
Enabled minor modes: Auto-Composition Auto-...
0
votes
4
answers
63
views
Text representing a Python vector of numbers: how to append a comma to each numeral but the last?
The printed value of Python vector of numbers is displayed in a buffer:
[0.00000024 0.00000024 0.00000024 0.00000024 0.00000024 0.00000023
0.00000024 0.00000024 0.00000024 0.00000024 0.00000023 0....
2
votes
0
answers
42
views
How to edit keyboard macro saved in file?
Here is my custom keyboard macro:
(fset 'gen-numbers
(lambda (&optional arg)
"Keyboard macro."
(interactive "p")
(kmacro-exec-ring-item
(...
1
vote
0
answers
35
views
How to cycle between literals at the cursors point?
Are there packages that can quickly toggle/cycle values under the cursor?
For example:
t <-> nil
<= <-> >=
+ <-> -
when <-> unless
... using a list of preset values for ...
1
vote
1
answer
32
views
How to keep a multi-line nested bullet list indentation (and bullets if possible) when pasting from Google Docs to emacs
I copy a nested list like this:
- foo
- bar
- foo
- bar
from Google Docs to emacs, but the bullet points vanish and the indentation as well. The same happens in the normal Linux text editor....
1
vote
2
answers
43
views
How to warn before editing or saving a buffer whose underlying file no longer exists?
(NB: In this post, I will use expressions like "a buffer's underlying file" to mean, in the Emacs' documentation's terminology, "the file a buffer is visiting", i.e. the value of (...
0
votes
1
answer
78
views
How to make backward-kill-word and kill-word stop after it kills a newline character?
kill-word and backward-kill-word deletes too much text:
foo(bar)
<point>
Now if I press C-<backspace>:
foo(<point>
What I want is:
foo(bar)<point>
after pressing C-<...
0
votes
1
answer
24
views
debugging why emacs is autoformatting on save hook
I'm currently facing an issue where I am trying to save a file, but some save hook is triggering an auto formatting the file in a way that I do not want. I am not sure how to debug this issue. Ideally,...
0
votes
2
answers
241
views
Filter text of buffer in a grep-like way
I want to filter the text of an emacs buffer, a bit like you can filter text with grep.
Sounds simple, but I tried googling it and I only get results from people who want to search in a buffer or to ...
0
votes
2
answers
33
views
Is there a way to delete the content under selected headers, but not the headers (and subheaders) themselves?
Is there a way to delete the content under selected headers, but not the headers (and subheaders) themselves?
I.e.,
** TOC
*** PART 1: VECTORS AND GRAPHICS
[[https://livebook.manning.com/book/math-...
0
votes
0
answers
26
views
Edit wikitext using Doom Emacs
I might have to edit some wikitext files. I am using tiddlywiki but the syntax is similar to mediawiki.
I looked up but could not find any specific mode to edit wikitext documents. HTML goes closest ...
1
vote
0
answers
82
views
Really slow editing long org-mode blocks
When editing inside a long org-mode block (#+BEGIN_.... - #+END_....) Emacs is really slow (it can take several seconds to write a single character), while editing the rest of the buffer takes normal ...
2
votes
1
answer
50
views
Unrestricted movement of lines Alt-Up/Down
I'm learning Orgmode and moving lines (headers, checkbox items) up and down.
These movement are restrited to a tree part of the line (header section, checkbox list):
* Here is a list
- Item 1
- Item ...
1
vote
2
answers
70
views
Text editing with parentheses
I have a text like Code1. I want to convert from Code1 to Code2, including parentheses and removing some texts. How do I edit this efficiently?
Code 1
AAA & 0.076 & 0.053 & 0.053\\
AAA &...
0
votes
1
answer
71
views
Change vertical characters to horizontal
I have the following data and want to change from Code 1 to Code 2. Is there any useful method to do that?
Code 1
11130101
11130102
11130201
Code 2
11130101, 11130102, 11130201
1
vote
1
answer
43
views
How to duplicate text but increment a numeric part of a name?
Say that I have rect1 one and I'll multiply it 3 times by yanking.
let rect1 = Rectangle {
width: 10,
height: 40,
}
let rect1 = Rectangle {
width: 10,
height: 40,
}
...
0
votes
0
answers
54
views
How to format code similar to the way Vim has (select + "=")?
In Vim I can format code by the key =, with or without selecting a region. Is there a way to do it in Emacs in an easy way too?
0
votes
0
answers
64
views
Adding custom text above and below a buffer
Is there an easy way to wrap a buffer in emacs with text of my choice? For e.g if my selected buffer is like this,
This is the first line of a verse with ।
And here comes the second line ॥ 1.2 ॥
I ...
0
votes
1
answer
800
views
Search and replace in evil mode
I'm an emacs newbie and am using evil mode for text formatting. I have some text in the following format:
word1 = meaning with elaboration; word2 = simpler meaning; word3; word4 = much long ...
7
votes
1
answer
206
views
Is there a convenient way to swap two words that aren't adjacent?
I've recently been editing some source code where I often want to swap elements in an array that spans multiple lines.
Doing this manually is quite tedious, moving the cursor between both locations ...
0
votes
0
answers
20
views
Bug? Can get point into the middle of a run of characters with a replacing display spec
I'm implementing a minor mode that "folds" certain strings. It does this by adding a font-lock keywords rule to the buffer, that applies display properties that make it look like it's a ...
1
vote
1
answer
35
views
How can I catch a block of text to be used in a replacement-part code?
I want to save a block of text in a variable and then do a replacement using that variable in the replacement part.
For instance, suppose to do the following replacement:
block_of_text
--->
\...
1
vote
0
answers
175
views
How can I convert an inline pseudo YAML dictionary to a valid multiline one?
Consider this code:
- name: Cron set up
cron: name=something something="anything" job="/bin/bash -c 'service=nslcd; [[ -x /usr/bin/$service ]] && systemctl restart $service'&...
5
votes
4
answers
611
views
How to swap words `true` and `false` in buffer text?
I found myself switching the text true to false, and vice versa, while coding very often. It's quite tedious to mark the entire thing and replace it with opposite. It would be great to have a function ...
1
vote
1
answer
60
views
Which setting controls the replacing of selection with the character we type?
When wanting to replace a region of text with another, I usually mark them with C-SPC (set-mark-command), press some arrow/movement keys, then type the text that I want. To illustrate:
I like biscuits....
2
votes
3
answers
234
views
How copy current line to the clipboard?
This Emacs Wiki page
says:
‘C-a C-SPC C-e M-w’ copies the current line without the newline.
But it doesn't work to me. I'm using Emacs 26. Is there some other shortcut?
P.S.
I use CUA keys in my ...
0
votes
1
answer
66
views
How can I insert some multiline text that respects the indentation at which it is inserted?
I have a function that reads a link from the clipboard and generates a metadata-ful markdown link from it, and inserts it:
(defun night/unt ()
(interactive)
(let* ((link (current-kill 0))
...
3
votes
1
answer
61
views
Centering within comment blocks or ASCII art
I have C comments like this:
/******************************************************************************
* Includes *
***********...
0
votes
1
answer
35
views
File within a root grandparent is detected by emacs as belonging to a directory that doesn't exists
I'm editing a file within a directory /parentdir/userdir/file with the following permissions:
$ sudo namei -l $(pwd)
drwxr-xr-x root root /
drwx------ root root parentdir
drwx--S--- ...
4
votes
1
answer
84
views
how to do simple calculations on numbers in text
I have a Json file containing a quite a few coordinates like {x: 400, y:200}
And I want to change the numbers for the y values in something like y:y_default + 120. (y_default = 80). Is there a quick ...
1
vote
1
answer
82
views
How to enter overlined characters?
Example: R̅E̅S̅
What I already tried, to no avail: Type R, followed by C-x 8 RET OVERLINE RET
What works but is not nice: Copy the example above and edit it.
1
vote
1
answer
32
views
Add a border around the region by inserting a given character
There's here, for example, given text:
WASP-41b 0.94 1.18 3.052404 0.04 1244 transit 590 0.93 5545
WASP-42b 0.527 1.122 4.9816819 0.0561 ...
1
vote
2
answers
300
views
org -- preserve white space on export to odt
i write poetic texts in org mode and i'd like to be able to export them to odt with their horizontal spacing preserved if possible.
it's poetry but not of the traditional kind. text is often heavily ...
0
votes
1
answer
226
views
orgmode: underscore automatically generates math-mode
When I type an underscore _ in org-mode, it automatically generates math mode, i.e. $_{}$ and it puts the cursor between the braces. Is there a way to disable this when in edit mode but not in math ...
2
votes
1
answer
67
views
Query replace regexp with a distant match?
I have a single transcript file for a set of course lectures I am watching. After doing some formatting on the file. I have it broken up into sets of lessons where the main heading is the lesson title ...
0
votes
1
answer
38
views
Insert aligned multi-line text in current buffer regardless of position?
I'm creating a function to easily insert ditaa boxes while drafting reports in org-mode. I have the meat of the function accomplished, but not sure how to implement it so that boxes can be inserted ...
0
votes
1
answer
92
views
need help with very complex find and replace
I have a very complex (at least to my mind) text replacement task. ideally this would be a function or macro I could run over every org header in a buffer.
I want to
1. move over any TODO state to a ...
0
votes
3
answers
99
views
how to convert 4 lines block text to 1 line space interrupted
I have a text file (name, surname, phone number)
than I would import in excel and the play with column (name, surname...)
The file was previously a docx file.
I've converted it on as a text file.
But ...
1
vote
1
answer
235
views
Insert White-space to Right to Even Out Region
Lets say I have the following block of text:
----
##
----
##
----
There is no white space after the # character. Is there some command to insert white space to the right of lines to even them with ...
1
vote
1
answer
219
views
How to sort comma separated (or otherwise) text?
Suppose I have the following text:
int z;
int a;
int c;
int g;
or the following text:
z, a, c, g
How can I sort them to:
int a;
int c;
int g;
int z;
and
a, c, g, z
respectively?
0
votes
1
answer
51
views
`Alt-f` or `Alt-b` then `d` deletes the forward word rather than putting character 'd' in front of the word. Why does emacs behave in this way?
I was doing some editing in Emacs. I was using Alt-f and Alt-b to traverse by word. I wanted to add the character d in front of a word. So I pressed Alt-b to get to the front of the word and then ...
4
votes
1
answer
103
views
How to replace the buffer without slowing down the undo system?
Say I have a command that operates on the entire buffer.
The simple solution is to:
Run the command taking the entire buffer as input.
Store the output.
Clear the current buffer.
Insert the new ...
0
votes
2
answers
52
views
Prepend to block of text, but ignore blank lines
How to add the string 'export ' to the beginning of each line of this text,
with emacs:
RBENV_VERSION="2.n.0"
AUTHORIZE_NET_API_LOGIN_ID=example
AUTHORIZE_NET_TRANSACTION_KEY=example
# Google ...
2
votes
2
answers
164
views
How to transpose words, keeping the cursor at the same relative location to the word it moves?
When transposing words, the cursor moves to the end of the word, how can the cursor be kept at the same location relative to the word?
0
votes
1
answer
82
views
How to transpose words backwards?
Transpose words (M-t) always swaps the word with the next.
How can this be performed with the previous word?
2
votes
2
answers
72
views
Temporarily restrict editing to whitespace only
Sometimes I make whitespace cleanups to source code. I'd like to be certain that I do not accidentally introduce real code changes (let us assume that the programming language is one where removing ...
4
votes
3
answers
179
views
Why multiple-cursor ask me on every line? How avoid this?
emacs 26.1, multiple-cursor https://github.com/magnars/multiple-cursors.el
Here my custom Elisp function that add some number(by default 1) to number.
(defun increment-number-at-point(number)
(...