If the mode line shows a (DOS) indicator, click on it twice to cycle to : meaning Unix newlines and then save the file.
If you can't click on the mode line or prefer a keyboard-based solution, run the command C-x RET f (set-buffer-file-coding-system) and type unix. This will change the encoding of newlines without changing the encoding of other characters. (...
(when (fboundp 'electric-indent-mode) (electric-indent-mode -1))
That works with any Emacs version. This annoyance or shiny-new-feature, depending on your point of view, was introduced as the default in Emacs 24.4.
See also this similar post on StackOverflow.
(However, it sounds like you are saying the reverse, and that you ...
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 line."
(defun insert-line-above ()
"Insert an empty line above the current line."
You are confusing a few things, here.
First, RET is not a physical (keyboard) key. It is a logical key -- the Emacs way of writing what your physical Return or Enter key typically sends to Emacs: a Control-M character (which Emacs also writes as C-m, when describing the Ctrl + m key sequence). And if your physical Return or Enter key sends something else, ...
(This is too long for a comment, and while not literally an answer, I hope it might help the OP.)
While Drew's answer covers what you literally want, this is probably not what you need. Point in Emacs is never on a character, it is between characters:
Like other positions, point designates a place between two characters
(or before the first character, ...
On the left side of the modeline, you'll see (DOS). This means that Emacs is viewing the buffer as if it had DOS-style line endings. To view the buffer as if it had Unix-style line endings, use the command revert-buffer-with-coding-system (bound to C-x RET r or C-x C-m r), and select something like utf-8-unix. Then the ^M characters will be visible.
You can always check what function some keys are bound to using C-h k. For example, if we type C-h k C-e, we see that it is bound to (move-end-of-line ARG); similarly, C-j is bound to (newline-and-indent).
In this case, it turns out that C-e C-j is a sequence of two commands rather than a single thing. (The same with C-a C-o TAB.) To bind this to a single ...
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:
\\ is only required to add additional empty lines.
Bind C-e to a command that puts the cursor one char to the left of the line end.
(defun foo (arg)
(unless (bolp) (backward-char)))
(global-set-key "\C-e" 'foo)
(Although I cannot imagine why you would want to move the cursor there.)
Save the file, and Emacs will automatically use the correct newline char when writing the buffer to file, according to the value of buffer-file-coding-system.
To know what is the value of buffer-file-coding-system, call describe-variable then buffer-file-coding-system, or run the describe-coding-system command which you can do by clicking the second ...
You need (interactive "P") (not "p") to get a raw prefix argument (i.e. the ability to distinguish between C-u and C-u 4). See C-h f interactive.
The raw prefix argument for C-- is not (-1), but -. See C-h i g (elisp) Prefix Command Arguments.
open-line takes a required argument.
(defun advanced-return (&optional arg)
(if (equal ...
While erjoalgo's answer is correct, according to the Emacs Wiki Mutliline Regex page, it is not the most efficient answer:
To match any number of characters, use this: .* – the problem is that . matches any character except newline. What many people propose next works, but is inefficient if you assume that newlines are not that common in your text: "\\(.\\...
Actually, I just noticed I can do this with \(.\|[\n]\)*. For example,
[code] $ sudo wpa_supplicant -B -i wlan0 -Dwext -c universitywpa
Successfully initialized wpa_supplicant
ioctl[SIOCSIWENCODEEXT]: Invalid argument
ioctl[SIOCSIWENCODEEXT]: Invalid argument
(re-search-forward "[code]\\(\\(.\\|[\n]\\)*?\\)[/code]" )
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:
The following code alters the visual display by adding an additional new visual line, but does not actually add new lines to the current document:
(aset (or ...
Maybe something like this:
(defun newline-and-indent-same-level ()
"Insert a newline, then indent to the same column as the current line."
(let ((col (save-excursion
To see what command a key is bound to at any point, use the key help commands. Type C-h c RET to see what RET is bound to. In a minibuffer, that's minibuffer-complete-and-exit. Because a minibuffer is active, the message will only appear for a brief time; switch to the *Messages* buffer if you haven't had time to read it.
The full message you'll see is
If you just want to insert newlines, without any automation for indentation or support for soft newlines, then you can use quoted-insert (C-q), which lets you enter any character including control characters. A newline character is C-j, but the Return key sends C-m, so you need to type C-u 1 0 C-q C-j (insert a newline, times 10).
If you want to call the ...
Usually, Tramp shall respect encoding of existing files. For new files, you could set the encoding via C-x RET f utf-8-unix RET. You can choose also another coding system, the important point is to append the -unixsuffix. Read also the Emacs manual about coding systems.
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 string,
$ for end of string,
[[:space:]]* zero or more spaces.
Ergo, if the first two meta-characters are next to each other or if there is one or more ...
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 newline, so you would write
to search for two consecutive newlines. You can then use a replace-match command for the replacement.
First, ^M is the carriage-return character, not the linefeed char (that one is ^J.
Here is one answer for this part of your question: How to
show the line feed chars - ^M in its original form and not as $:
By default, ^M characters should be highlighted using face escape-glyph. Are you sure this is what you are seeing? Try customizing that face (M-x ...
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 select a window of the buffer with the test text,
call M-: and paste the following lisp snippet into the minibuffer.
(setq-local search-whitespace-regexp ...
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 have no escape sequences in regular expression syntax at all -- they must appear literally in the pattern.
In double-quoted strings, however, you can use "\n" ...
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 of indentation, and also comment continuation when you're inside one.
In programming modes I make RET do whatever M-j does:
(defun my-coding-config ()