67 votes

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

I personally stick to writing things in org-mode with flyspell-mode and langtool... org-mode is fantastic for typing any sort of document quickly in Emacs, flyspell takes care of spelling, and ...
user avatar
  • 2,046
57 votes
Accepted

How to add a prefix to every line?

You can add a prefix with M-x string-rectangle, which is bound to C-x r t. This is part of a series of commands that operates on rectangular selections; this one inserts text at every line in the ...
user avatar
34 votes

How to add a prefix to every line?

You could use multiple-cursors-mode, to put a cursor on every line. Then, any text you type will be inserted on each line. You would start out with the point at the beginning of the piece of code: ▮...
user avatar
  • 5,864
32 votes
Accepted

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

It's even easier! Again, use rectangle commands. Move to one corner of the rectangle you want to delete, press C-SPC to set the mark. Move to the other corner of the rectangle and press C-x r d (...
user avatar
29 votes

How to add a prefix to every line?

Personally, I prefer replace-regexp (replace "^" with "I said ").
user avatar
  • 2,167
25 votes
Accepted

Opposite of fill-paragraph

Quoting from Emacs Wiki, by Stefan Monnier: Unfilling a paragraph joins all the lines in a paragraph into a single line. It is the contrary of FillParagraph. It works where a line ends with ...
user avatar
  • 6,594
24 votes

How to add a suffix to every line of a text?

Very easily, fortunately. Use C-M-% (which runs the command query-replace-regexp), use the regexp (regular expression) $ (this matches exactly at the end of line) and replace it with your text. And ...
user avatar
  • 3,361
21 votes
Accepted

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

There are two cases I can think of: reactivating the region, and adjusting the size of the region. I most often use this binding to reactivate the region after performing some command that ...
user avatar
  • 19.4k
20 votes
Accepted

Fixing DOuble CApitals as I type

Here's a function that will convert DOuble CApitals to Single Capitals. I'd originally suggested adding it to post-self-insert-hook, but below is an option for a glorified minor mode so that you only ...
user avatar
  • 31.1k
18 votes
Accepted

Removing smart quotes automatically

Based on SU : How to remove smart quotes in copy Paste You can try something like the following: (defcustom smart-to-ascii '(("\x201C" . "\"") ("\x201D" . "\"") ("\...
user avatar
18 votes

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

Another answer: use M-x picture-mode. You can kill or copy rectangles through the middle of tab chars etc., send them to registers, etc.
user avatar
  • 70.3k
17 votes

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

Ask Emacs: C-h r i exchange-point-and-mark RET or, better, C-h r i C-x C-x RET. This takes you to the information shown below. This is what the Emacs manual, node Setting Mark says in answer to your ...
user avatar
  • 70.3k
16 votes

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

The EmacsWiki category Writing is the place to start. It lists dozens of libraries that support writing text using Emacs, with one-liner descriptions and links to the detail pages. There is no sense ...
user avatar
  • 70.3k
16 votes

How do I delete all blank lines in a buffer?

From MasteringEmacs.com By Mickey Petersen: This is a frequent question so I figured I’d mention the solution here: You want to remove all empty (blank) lines from a buffer. How do you do it? Well, ...
user avatar
  • 1,968
15 votes

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

I write novels using Emacs, and have developed a workflow over time based on certain unique advantages of it. (Example: My most recent book was conceived, composed, and edited with Emacs.) That said, ...
user avatar
15 votes
Accepted

Compose key in Emacs: <Multi_key> is undefined

Run emacs with XMODIFIERS set to @im=none: XMODIFIERS=@im=none emacs I'm surprised this still happens; I found this workaround some time ago, and forgot about it. I would have assumed it would get ...
user avatar
15 votes
Accepted

unicode.txt slowness

Reading the GitHub discussion thread linked in @wvxvw’s comment, I discovered the variable inhibit-compacting-font-caches. Setting it to non-nil solves the issue: (setq inhibit-compacting-font-caches ...
user avatar
  • 989
14 votes

How to add a prefix to every line?

Another option is to use macros, which can handle more tasks than rectangular selections or multiple cursors, even if it's a little clunkier for this specific case. Position the cursor at the ...
user avatar
  • 2,781
13 votes
Accepted

How to right align region and/or line?

According to the manual node on Filling, several of the fill functions take an optional JUSTIFY argument that you can use. So, for example, to fill a paragraph with right justification, you can use (...
user avatar
  • 31.1k
12 votes
Accepted

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

If you want to copy some information to another buffer, and from then on let the buffers evolve independently, you can do just that. But if you want the other buffer to reflect the original content ...
user avatar
12 votes
Accepted

Replace text inside various delimiters (eg: brackets, quotes)

Using expand-region I would recommend installing the expand-region package (available on Melpa too). It would be useful for editing situations mentioned in your example and lot more. expand-region is ...
user avatar
  • 24.3k
12 votes

Drag selected text with the mouse

tldr; Add (setq mouse-drag-and-drop-region t) in you init file. Restart or C-c d R to reload if you're using Doom-Emacs. I just find out (SURPRISINGLY) that Emacs as text drag and drop. And this ...
user avatar
  • 339
12 votes

Hightlighting all occurances of selected text

Functionality built-in to emacs: With point on the word in question, type M-s h . to highlight all occurrences. Note that this matches the entire word, not substrings. Repeat this multiple times, ...
user avatar
  • 1,279
11 votes

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

Spin off of the original answer to the linked question. Grammar Check: I am not aware of any dedicated grammar parsers for emacs yet. I will mention writegood-mode available in MELPA which highlights ...
user avatar
  • 3,836
11 votes

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

I think this is a great question. I'm sure there are tons of super helpful modes that fiction writers don't know they need. I happened upon palimpsest-mode by accident, but now I couldn't live without ...
user avatar
11 votes

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

If you are continuously typing text without making mistakes or editing, then the end result would be the same in both cases. auto-fill-mode isn't so helpful when editing existing text, though (...
user avatar
  • 43.9k
11 votes

Is there a convenient way to swap two words that aren't adjacent?

Function transpose-words can do that. Set a mark at one word (C-SPC). Move the cursor to the other word. C-0 M-t Enjoy!
user avatar
  • 2,646
10 votes
Accepted

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

You need to (before adding property read-only), make the first character have a value that includes read-only for property front-sticky: (put-text-property 1 2 'front-sticky '(read-only)) ; Do this ...
user avatar
  • 70.3k
10 votes

How to add a prefix to every line?

You could install evil and do it in any number of vi-like ways - I prefer visual block selection using Ctrl + V to mark each line and then Shift + I to insert and then type the text you want to insert ...
user avatar
10 votes
Accepted

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

The extend-rectangle-to-end function in the rectangle-utils package is what you want. It's on melpa. It inserts spaces to make the current rectangle selection extend to cover the longest line in the ...
user avatar
  • 1,439

Only top scored, non community-wiki answers of a minimum length are eligible