37 votes

org-mode , export , how to 'force' newline on lines between paragraphs?

is #+OPTIONS: \n:t what you want (see org-export-preserve-breaks)? place this line anywhere in your org-file to preserve line breaks. ref: The Org Manual/Exporting/Export settings
nichijou's user avatar
  • 1,188
13 votes
Accepted

Insert line above/below

The special form which saves and restores the current point and buffer is save-excursion. So you could write your functions as: (defun insert-line-below () "Insert an empty line below the current ...
Basil's user avatar
  • 12.4k
9 votes

org-mode , export , how to 'force' newline on lines between paragraphs?

To separate paragraphs by a single line all you need is to add an empty line between each paragraph in your org-file like following: First paragraph Second paragraph \\ is only required to add ...
CantrianBear's user avatar
6 votes
Accepted

How to remove empty lines of a selected region of code in Emacs?

Select what you want to change, or C-x h to select the whole buffer. Then: M-x flush-lines RET followed by ^$ RET or ^[[:space:]]*$ RET ^[[:space:]]*$ contain the meta-characters: ^ for beginning of ...
Nsukami _'s user avatar
  • 6,521
5 votes
Accepted

setq require-final-newline not working when setq-default does

You need to either set the default value of the variable, if you want it for every file: (setq-default require-final-newline t) ;; or ... (customize-set-variable 'require-final-newline t) or to set ...
NickD's user avatar
  • 29.8k
4 votes

Imitate paragraph spacing in visual line mode

This same or similar question was previously asked on stackoverflow: https://stackoverflow.com/questions/24838516/how-to-set-paragraph-spacing-in-emacs Here is a regurgitation of my prior answer: ...
lawlist's user avatar
  • 19.1k
4 votes

How to count the number of lines between two points? (ignoring word wrap)

There is a function to count lines. (count-lines beg end) Found this soon after posting.
ideasman42's user avatar
  • 8,806
3 votes
Accepted

Specify the number of blank lines

Just use C-q C-j after your prefix command. C-q generally instructs emacs to insert the next key sequence verbatim.
cyberbisson's user avatar
3 votes

Search and replace two consecutive newlines

Interactively, you can use replace-regexp for this. Type C-q C-j to insert a newline character in the minibuffer (so you would need to type this twice). In Elisp strings you can use \n to indicate a ...
StarBug's user avatar
  • 479
3 votes
Accepted

Mapping RET to use the same indentation level as the previous line

Maybe something like this: (defun newline-and-indent-same-level () "Insert a newline, then indent to the same column as the current line." (interactive) (let ((col (save-excursion ...
glucas's user avatar
  • 20.6k
3 votes
Accepted

How to switch off showing a line break marking dollar sign $ at the end of a line?

Thanks for Fran Burstall's answer, but it has some disadvantages. So I post this answer as another choice. Since OP has toggled whitespace-mode on, so simply disabling whitespace-newline-mode will ...
shynur's user avatar
  • 5,308
2 votes

How to make a dot match a newline

At least in emacs-27, the elsip info page "regexp special" answers the question: If the lower bound of a range is greater than its upper bound, the range is empty and represents no ...
hugobam's user avatar
  • 21
2 votes

How to disable auto-indentation of new lines?

There is the possibility to insert a newline char with C-q C-j and there are 3 commands to split the line: open-line C-o, split-line C-M-o and the newline RET, C-m you used. If you position the cursor ...
2 votes
Accepted

How to disable fill-column-indicator (fci) when it's outside the window?

Here's a workaround that displays fci when its needed. Note that while it takes horizontal scroll into account, I couldn't find a hook to run when horizontal scrolling changes. if fci-rule-column ...
ideasman42's user avatar
  • 8,806
2 votes

Search for "foo bar" ignoring comments and newlines

I can fake this via C-hv search-whitespace-regexp It wouldn't be a full solution unless your comment marker character could never occur in any other context (e.g. the string "100%"). For testing ...
phils's user avatar
  • 51.3k
2 votes

How to set default encoding to utf-8, and default line ending to linux style?

For current release of emacs (26.1): (setq-default buffer-file-coding-system 'utf-8-unix) Verify with C-h v buffer-file-coding-system. It should say "global value is utf-8-unix".
Kenyon's user avatar
  • 121
2 votes
Accepted

How to set default encoding to utf-8, and default line ending to linux style?

;; make unix lineendings default (setq default-buffer-file-coding-system 'utf-8-unix)
Maxim Kim's user avatar
  • 1,766
2 votes
Accepted

elisp regex newline escape confusion

Newline and tab are both escaped with a single backslash, because they are escape sequences for the read syntax for strings, and not escape sequences for regular expression syntax. Those characters ...
phils's user avatar
  • 51.3k
2 votes

Continue comment while editing lisp and when hitting enter

The standard key for this behaviour is M-j. It is bound to indent-new-comment-line by default but, depending on the buffer, may be bound to some other mode-specific analog. These commands take care ...
phils's user avatar
  • 51.3k
2 votes

How to find a newline with a regular expression in query-replace-regexp?

OK, this has been driving me nuts every time I've run into it for over a year now and I finally sat down and figured out what is going on... Unfortunately I don't have a fix---only the actual ...
kspurgin's user avatar
2 votes
Accepted

Is there a way to automatically indent a parenthesis in Slime REPL after pressing `C-m o`?

C-j runs slime-repl-newline-and-indent which I think will work. Whenever I'm faced with an unfamiliar mode, I do C-h m which shows me mode information, including the keymaps: I can then zero in on the ...
NickD's user avatar
  • 29.8k
2 votes
Accepted

How to perform a multi-file regex-search with a regexp that encompass several lines?

I don't think you want to just use a single regexp to search for defcustoms that have either :set or :initialize, with (or without) any of those things possibly being on different lines. Why? Because ...
Drew's user avatar
  • 77.6k
2 votes

How can I make isearch match phrases across line breaks?

Option search-whitespace-regexp: search-whitespace-regexp is a variable defined in isearch.el. Its value is "\\s-+" Documentation: If non-nil, regular expression to match a sequence of ...
Drew's user avatar
  • 77.6k
2 votes

How to repeat the last yank command N times?

If you want to yank something N times, the simplest approach is probably to use a keyboard macro: See https://www.gnu.org/software/emacs/manual/html_node/emacs/Keyboard-Macros.html. For example, mark ...
glucas's user avatar
  • 20.6k
2 votes

Search and replace to merge or eliminate text lines

I know that you are looking for an Emacs solution and it may be that somebody will provide one, but that's the wrong way to go about the problem: you should use the right tool for the job. There is ...
NickD's user avatar
  • 29.8k
2 votes
Accepted

How can I make occur display only first line of match?

(add-hook 'occur-mode-hook (lambda () (setq-local outline-regexp "^[[:blank:]]*[[:digit:]]+:" outline-level (lambda () ...
shynur's user avatar
  • 5,308
2 votes

In an Elisp regexp, does anchor `^` not work with new line in front?

The answer can be found in the Gnu Manual: ^ is a special character that matches the empty string, but only at the beginning of a line in the text being matched [...] For historical compatibility ...
rsp's user avatar
  • 191
1 vote
Accepted

How to ignore emtpy lines on the bottom of the buffer?

This answer uses following answer's code with a small change Can page-down clamp the last line to the bottom of the window?. I just replaced (my-scroll-and-clamp--forward-line height) with (end-of-...
alper's user avatar
  • 1,370
1 vote
Accepted

Spacemacs move cursor using word wrap, not line breaks

I finally got it working. Emacs has the line-move-visual variable, but spacemacs requires spacemacs/toggle-visual-line-navigation to be run instead. If you want this command to modify the bindings for ...
GammaGames's user avatar

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