We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [text-editing]

Questions about editing or manipulating text inside of Emacs.

Filter by
Sorted by
Tagged with
58
votes
5answers
6k views

What options are there for writing better non-programming text in Emacs?

This is a fork from the question What options are there for doing spell-checking in Emacs? Because I'm currently doing a lot of non-programming tasks in Emacs I'm wondering whether Emacs can support ...
35
votes
7answers
5k views

How to add a prefix to every line?

I have the code below: Hello There I am some code And want to add code in front of it, like: I said Hello I said There I said I am some code So how would I add a prefix to each line?
32
votes
10answers
7k views

Kill or copy current line with minimal keystrokes

I do C-a C-k C-k to kill the entire line point is on. If I want to copy the line instead of killing it, I can hit C-/ C-/ right after typing the sequence above. Alternatively, I can do C-a C-SPC C-...
31
votes
5answers
3k views

Is there a way to use query-replace from grep/ack/ag output modes?

I'm aware of find-grep-dired, marking the corresponding files and then pressing Q to run dired-do-query-replace-regexp on the marked files. Unfortunately that requires restarting the grep and no ...
25
votes
6answers
2k views

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?
23
votes
3answers
1k views

Fixing DOuble CApitals as I type

I have a bit of a slow pinky. As my other fingers get faster and faster at typing, my pinky just can't keep up. This frequently leads me to type sentences whose first word starts with two uppercase ...
18
votes
2answers
965 views

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, ...
17
votes
1answer
2k views

How to automatically create neat C comment blocks while typing?

Some code editors such as eclipse automatically form neat blocks when you start typing a multi-line comment: Is there some package or another way to do this in emacs too? Edit: To clarify: I do not ...
16
votes
4answers
1k views

What is the usefulness of `exchange-point-and-mark`?

The exchange-point-and-mark command is bound to C-x C-x, but I cannot think of any use cases that would make it deserving of such a prominent binding. How can I use the exchange-point-and-mark to ...
16
votes
2answers
1k views

How to act on rectangles beyond the end-of-line?

Here's what Vim's documentation has to say about it: Virtual editing means that the cursor can be positioned where there is no actual character. This can be halfway into a tab or beyond ...
16
votes
1answer
411 views

Is there a 'local undo' extension for Emacs?

It happens quite often that I want to undo changes locally or line-wise. For example, when I change multiple lines in a source code and I want to revert only one of them, then I have to step through ...
16
votes
1answer
2k views

What am I giving up by activating CUA mode?

CUA mode is very close to the workflow I am used to outside Emacs, so I am tempted to activate it. But I have learned that Emacs may have useful gems hidden in its ways, and CUA mode seems something ...
15
votes
6answers
3k views

How to delete the first few n chars of every line?

I recently asked: How to add a prefix to every line? So go from the code below: I said Hello I said There I said I am some code To code like: Hello There I am some code Now, how do I delete n ...
14
votes
1answer
882 views

How to view and edit large delimiter separated value files?

I have been using csv-mode to modify small to medium sized CSV files, but recently I have been working with large files containing more than 40,812 entries. csv-mode struggles to align and navigate ...
13
votes
1answer
2k views

How to edit crontab directly within emacs when I already have emacs open?

I know I can set the EDITOR variable and edit my crontab with emacs but that requires starting the process from a shell with $ crontab -e My question is how can I directly modify my crontab if I'm ...
13
votes
3answers
1k views

Move form up and down on paredit mode

I've been using cursive's Structural Editing (a paredit-like mode for Intellij and Cursive) and I found a nice command there called move form-up (and down). Move form up does this (the | is the ...
13
votes
2answers
2k views

Compose key in Emacs: <Multi_key> is undefined

I set the Alt Gr key on my keyboard as compose key in my system (Ubuntu 14.04) in order to type letters like éóèàùçü and so on. But when I am on Emacs and try to press the Alt Gr key, I have a message ...
12
votes
9answers
2k views

How to edit elisp without getting lost in the parentheses

I'm modifying some elisp code from linum.el: (custom-set-variables '(linum-format 'dynamic)) (defadvice linum-update-window (around linum-dynamic activate) (let* ((w (length (number-to-string ...
11
votes
3answers
1k views

How to wrap given text around region

I often have a situation where I need to apply text around a region. For HTML and simple cases there are libraries for this already. But what about the general case? I'd like to be asked what I'm ...
11
votes
3answers
1k views

How to transpose two arguments of a function in Python?

How I can I swap two arguments in a call to a Python function? If I put point on the space between these two arguments: self.assertEqual(json.loads(some.data), json_data) and then M-t (transpose-...
11
votes
2answers
1k views

How can I draw pixel- or vector-based UI elements in Emacs?

With that I mean UI elements (for example text fields and animated buttons) that are not restricted to the monospaced character grid of terminal emulators, but can be arbitrary shapes at arbitrary ...
10
votes
3answers
999 views

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 ...
10
votes
1answer
1k views

How to right align region and/or line?

We can center text with M-x center-region and M-o M-s. Is there something similar for right-alignment? Example before: Item 0: value | Item 100:...
10
votes
3answers
392 views

Editing multiple source blocks in one buffer

I've got multiple source blocks which are all tangled to the same file. When I invoke C-c ' inside one block, only this specific block is shown in a new buffer. Is there a possibility to show all ...
9
votes
3answers
1k views

How do I outline/hide/show text when writing prose?

I want to use Emacs to write prose (specifically, fiction). I have used Scrivener and Ulysses in the past but I am not happy with them. I want to try Emacs, but don't know how to replicate the ...
9
votes
1answer
678 views

unicode.txt slowness

Moving around point (using the cursor keys) in Xah’s unicode.txt in fundamental-mode is noticeably slower than in an ordinary text file. Are the many non-ASCII characters the issue? Anything else? ...
9
votes
1answer
217 views

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, ...
8
votes
4answers
2k views

copy contents of current buffer in a temp buffer and operate on that

I need to copy the contents of the current buffer to a temp buffer, set that buffer to a particular major mode to take advantage of its benefits and get the information I need back to the main logic. ...
8
votes
4answers
493 views

Fastest way to move code block to specific line

Say you have code on lines 4, 5, 6. Then you want to move this block of code to starting point line 9 while also deleting lines 4, 5, 6. What's the fastest way, i.e. least amount of key strokes, to ...
8
votes
4answers
4k views

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 ...
8
votes
1answer
149 views

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 ...
8
votes
1answer
249 views

Prevent inserting text at the beginning of a buffer that starts with read-only text

I'm extending an existing Emacs package and I want to make a part of the buffer not editable (read only). In fact, I want to make only one line in the middle of the buffer editable and I use the ...
7
votes
2answers
325 views

GROUP BY + COUNT over lines in a region

What is the simplest way of getting the number of distinct repeated in a region? For example, from THIS IS LINE A THIS IS LINE A THIS IS LINE A THIS IS LINE B THIS IS LINE B THIS IS LINE C I would ...
7
votes
2answers
555 views

How to insert text after point?

I'd like to insert (programmatically) some text right after the point (without moving it). I came up with this: (save-excursion (insert "my text")) It seems to work. Is it a good way to do what I ...
7
votes
3answers
60 views

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 ...
7
votes
1answer
224 views

Increment days / months / dates, etc. within buffer

In a text document, while editing, I often need to increment/ decrement calendar data. So, Friday will need to become Monday, December will need to become March, etc. Or 28 Apr after adding 5 will ...
6
votes
3answers
175 views

What is the difference between refill-mode and auto-fill-mode in emacs?

I swear I tried to read documentations, but in practice, I could not tell the difference. I feel they are doing the same thing. I can turn both modes on, but I am not sure in what circumstance I need ...
6
votes
4answers
2k views

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 ...
6
votes
1answer
196 views

How do I delete all blank lines in a buffer? [duplicate]

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 ...
6
votes
1answer
407 views

how to move region to other window?

How can I automatically move selected to the other window? Trying to streamline my split-window workflow. Here's what I have so far. Doesn't work yet. (defun move-region-to-other-window (start end)...
6
votes
3answers
651 views

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 ...
5
votes
2answers
257 views

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 ...
5
votes
1answer
891 views

Drag selected text with the mouse

In many editors it is standard to move selected text by dragging and dropping it with the mouse. In emacs dragging selection with the mouse starts a new selection by default. This is extremely ...
5
votes
4answers
444 views

Add a constant decimal value to a column of numbers

Suppose I have a file containing the following: ATOM 10 H5 LIG 1 -0.684 2.034 0.000 1.00 0.00 ATOM 11 C1 LIG 1 0.974 0.686 0.000 1.00 0.00 ATOM 12 H1 ...
5
votes
1answer
191 views

How to make sure currently selected text gets deleted when typing new text?

When editing text, editors' usual behaviour is to replace selected text with the next text. In Emacs, when text is selected and you enter new characters, the new text gets inserted at point, leaving ...
5
votes
1answer
64 views

Is there a built-in or package solution for managing references in text files?

I'm currently writing up a design document and I want to include a number of references to external documents/URLs. I can manually add reference brackets and links so that: See the external file blah....
5
votes
2answers
716 views

Incrementing characters in Emacs, next to numbers?

You can place a pointer on a number, like 1, and increment it to 2. There are many alternatives on this. See also the Emacs Wiki: https://www.emacswiki.org/emacs/IncrementNumber 7 alternatives to ...
5
votes
1answer
146 views

Edit simultaneously many buffers and save all of them after edit

Windows 10, Emacs 25.1, Helm I open 3 different files: I need: Edit simultaneously all buffers. Add text "customer/" to the node "bodyFileName"in all buffers. After edit save all buffers, Here ...