Questions about editing or manipulating text inside of Emacs.
Questions tagged [text-editing]
221 questions
34
votes
6 answers
Opposite of fill-paragraph
Emacs has the function fill-paragraph. Is there any function which will do the opposite of that?
I have a paragraph which is already filled and instead I want it in a plain single line?

Sibi
- 3,683
- 2
- 24
- 35
21
votes
2 answers
Removing smart quotes automatically
Especially when copying text from things like Google docs, I would like Emacs to automatically remove smart double quotes, smart single quotes, and all manner of em-dash and en-dash characters, replacing them with their ascii equivalents.
Is there a…

Lee H
- 2,727
- 1
- 17
- 31
13
votes
1 answer
How do I delete all blank lines in a buffer?
Emacs 26.1
In buffer
1
2
3
4
I use command "delete-blank-lines". But it NOT delete ALL BLANK LINES. It's delete ONLY ONE BLANK LINE.
Why?
I need to delete ALL BLANK LINES.
The result must be like this:
1
2
3
4

a_subscriber
- 4,062
- 1
- 18
- 56
12
votes
4 answers
Hightlighting all occurances of selected text
Within Visual Studio and Notepad++, when I select a symbol (using the shift key or mouse), other occurrences of it within the buffer are also highlighted in another color.
When editing JavaScript or AutoHotkey or any other dynamic language where you…

Tahir Hassan
- 295
- 3
- 9
12
votes
4 answers
Replace text inside various delimiters (eg: brackets, quotes)
I often do some testing implementation with hardcoded values which I later want to change. Like
ref = open('specific-file-name')
Which I would like to change into
ref = open(fname)
I'm used to vim and there I can type ci(fname assuming that point…

kain88
- 835
- 7
- 19
10
votes
3 answers
Repeat last text insert
In Vim you can press . to repeat the latest change, including inserting text.
While in Emacs C-x z only repeats the last command. I am aware that macros can be used here, but more than often I realize that I need to re-insert the same text too late.…

ooi
- 283
- 1
- 7
9
votes
1 answer
make `delete-duplicate-lines` ignore blank lines and certain words
I'm editing a text in org-mode, several lines are repeated since they where part of different files from the same topic.
I want to use delete-duplicate-lines to delete the repeated lines, however, the command removes the blank lines too, which is…

shackra
- 2,782
- 19
- 49
8
votes
1 answer
Editing a string with lots of escape characters
Let's say I'm editing my config file and there is a very long string like this:
(setq my-string "very\nlong\nstring [...] \"hello world\"")
How do edit the string without the escape characters (and maybe in a different mode) and than save the…

allikotsa
- 115
- 4
7
votes
3 answers
How to blockquote text in one go
With this text:
Play with it a few times you will see my point. The
command you need is:
$ echo hello
How do I make it into:
> Play with it a few times you will see my point. The
> command you need is:
>
> $ echo hello
Without using the…

Tankman六四
- 213
- 1
- 4
7
votes
3 answers
What kinds of mistakes does transpose fix?
The only times I've ever found a use for transpose-words or transpose-chars is when I accidentally hit one of them unintentionally, in which case a backward-word followed by transpose-words again would undo the problem.
It seems like the use case is…

VF1
- 213
- 1
- 6
6
votes
4 answers
How to add a suffix to every line of a text?
Windows 10, Emacs 25.1
Suppose I have the following text (about 100 rows):
ic_m_sales
ic_m_activity_report
ic_m_messanges
ic_m_products_name
ic_m_change_store
ic_m_faq
...
How to add the same suffix (_inactive) to every line…

lmdic
- 123
- 1
- 7
5
votes
4 answers
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 that replaces word under the cursor to true if…

Navidot
- 772
- 5
- 13
5
votes
0 answers
how to convert camel case to snake case with vanilla emacs
When editing for example a ruby file,
can't emacs toggle CamelCase to snake_case out of the box?
Example ruby file
def SecDecGov
puts "abort"
end

american-ninja-warrior
- 3,903
- 2
- 24
- 44
4
votes
4 answers
Append region to the end of the lines of another region of same length
Here are two cases i am interested in:
Case 1: lines of identical length
Given some lines
const int name1
const int name2
const int name3
const int name4
and some other lines
= 1
= 2
= 3
= 4
I would like to move the other lines to the end of the…

Beginner
- 2,711
- 3
- 18
- 25
4
votes
5 answers
How to swap strings in all lines?
Emacs 26.1
I have this text:
"ADA-SGD"
"ADT-SGD"
"ADX-SGD"
"AID-SGD"
"AMP-SGD"
"ANT-SGD"
"ARDR-SGD"
"ARK-SGD"
I want to swap text in all these lines. The result must be like…

a_subscriber
- 4,062
- 1
- 18
- 56