The Stack Overflow podcast is back! Listen to an interview with our new CEO.
64

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 langtool worries about the grammar. Everything is highly customizable too, so you can customize anything to your heart's content. Here is a quick little type-up in ...


47

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 rectangle. Start by setting the mark at the beginning of the first line, and move your cursor to the first character of the last line you want to prefix: *Hello ...


32

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: ▮Hello There I am some code Then hit C-> twice. (This is the suggested key binding; you have to set it up yourself.) This creates two extra cursors on the ...


29

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 (delete-rectangle). For example, move to the first line you want to act on, press C-a or home to go to the beginning of the line, move down to the last line you want ...


26

Personally, I prefer replace-regexp (replace "^" with "I said ").


23

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 that's it! Another possibility involves Magnars Sveen's excellent multiple-cursors.el : select lines, use M-x mc/edit-lines then hit C-e (end-of-line) and start ...


19

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 a newline character (”\n”) and paragraphs are separated by blank lines. To make a paragraph end in a single newline then use the function below: ;;; It is ...


19

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 add to that hook when you really want it: (defun dcaps-to-scaps () "Convert word in DOuble CApitals to Single Capitals." (interactive) (and (= ?w (char-...


18

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.


18

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 deactivates it, or doing something that sets mark and moves point without activating the region. For example, do a C-s and search forward for something. Hit RET to ...


17

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 question: C-x C-x is useful when you are satisfied with the position of point but want to move the other end of the region (where the mark is). Using C-...


15

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, it is not a road without difficulties. Org-mode Org-mode is the reason I began using Emacs. Being able to fold and unfold sections of a ~50K-words manuscript ...


15

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 listing such info again here - consult it there. (But perhaps others here will have specific recommendations.) I will mention only the subcategory page ...


15

Based on SU : How to remove smart quotes in copy Paste You can try something like the following: (defcustom smart-to-ascii '(("\x201C" . "\"") ("\x201D" . "\"") ("\x2018" . "'") ("\x2019" . "'") ;; en-dash ("\x2013" . "-") ...


13

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 (fill-paragraph 'right). You can also use (justify-current-line 'right) for a single line. If you plan to use these options a lot, you could wrap them in ...


12

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 beginning of the first line and hit F3 to start recording, insert the text, move the cursor to the beginning of the next line and hit F4 to stop recording. Now hit F4 ...


11

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 weasel words and passive voice in the buffer. It gets you half the way there. Another possibly useful library is dupwords.el which can highlight if a ...


10

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 in real time, then Emacs provides this with indirect buffers. An indirect buffer is another buffer that has the same content as the original (modifications in ...


10

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 region. To get this behaviour, I've got this in my init.el. C-x r e is not bound to anything else in vanilla emacs (require 'rectangle-utils) (global-set-key ...


10

On Linux, and I assume Mac, you can pipe the region through the uniq shell command to get almost exactly what you want. Mark the region Sort the lines with M-x sort-lines Call shell-command-on-region with the prefix key: C-u M-| Enter uniq --count The contents of the buffer will be replaced by: 3 THIS IS LINE A 2 THIS IS LINE B 1 THIS IS LINE C You ...


10

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 since version 22.1 released in 2007. This is actually a feature I didn't even dare to google to see if it's available. Even Sublime Text can't (currently in Linux)


9

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 one first. (put-text-property (point-min) 50 'read-only t) See the Elisp manual, node Sticky Properties. The problem was that although the first char had a non-...


9

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 and finally hit ESC to exit insert mode and the text will be prepended to each line. This is very similar to emacs rectangle selections but a few less ...


9

The interactive special form provides the easiest way to get input from a user. (defun td (variable) (interactive "sVariable:") (insert (format "std::cout << \"%s is: \" << %s << std::endl;" variable variable))) Here "sVariable:" consists of the "s" code character (read a string) and the prompt. (See Using interactive in the Emacs ...


9

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 fixed by now. There are some bug reports around for this; I can't find the (Debian) one that I originally read to get this workaround, but one relevant to ...


9

You can use the package string-edit for that purpose. Essentially, it does exactly what you want: simply call string-edit-at-point to edit the string at point, then C-c C-c to return to the original buffer. The documentation on github includes a demonstration (if the link appears to be dead, please see the github page directly).


9

Try using dabbrev with M-/, it expands strings from the same and other buffers inline. A more powerful alternative you can customize with your own functions is hippie-expand.


9

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 it. I'd love to see what packages other fiction writers find useful. Here are some that I use every day: palimpsest-mode. Sends selected text to the bottom ...


8

Something like this: (let ((old-buffer (current-buffer))) (with-temp-buffer (insert-buffer-substring old-buffer) (my-favourite-major-mode 1) (extract-needed-information)))


8

Just add this line in your init file: (delete-selection-mode 1)


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