Questions tagged [newlines]
64 questions
67
votes
2 answers
How to convert DOS/Windows newline characters to Unix format within GNU Emacs?
Is there a way to tell GNU Emacs to convert DOS/Windows newline characters in a file to Unix format?

Charo
- 865
- 1
- 9
- 11
48
votes
5 answers
How to disable auto-indentation of new lines?
I've recently upgraded emacs to version 24.4.1 and something has changed in the indentation of new lines. When I hit enter I expect just "bare" new line character at point where cursor was present, in particular if I'm in the middle of the line,…

WeSenseASoulInSearchOfAnswers
- 1,383
- 2
- 14
- 16
26
votes
3 answers
org-mode , export , how to 'force' newline on lines between paragraphs?
I have an org-mode file, some sub-sections have some big paragraphs.
When I export as html the whole paragraphs are displayed as single lines.
I understand that I have to put a '\\' on every line, a bit PITA, its around 4000 lines there. Is there…

xMris
- 361
- 1
- 3
- 3
12
votes
2 answers
How can I suppress emacs' cursor moving into the empty last line of a file?
One of vim's quirks is that it doesn't show an empty line at the end of a file if the file ends with the newline character. This way, if the file doesn't end with a newline, the display is the same, only with the [noeol] marker in the…

sykora
- 269
- 2
- 10
8
votes
1 answer
How to examine the new line characters in emacs?
I want to check if there is a "\r" at the end of a line of a plain text file (compressed as .gz file). I try the whitespace mode, and I don't find ^M shown. Is \r shown as ^M in whitespace mode?
But my python program says something is wrong with…

Tim
- 4,987
- 7
- 31
- 60
7
votes
1 answer
Insert line above/below
I have a couple of functions for inserting blank lines above and below the current line:
(defun insert-line-below ()
(interactive)
(move-end-of-line nil)
(open-line 1))
(defun insert-line-above ()
(interactive)
(move-beginning-of-line…

Simon
- 411
- 6
- 15
7
votes
2 answers
Difference between the physical "RET" key and the command 'newline in the minibuffer
The key "RET" is bound to 'newline in many modes in Emacs as described in M-x describe-binding. But in the minubuffer,
they are different (try to send the command newline to the minibuffer).
So this question arises: In the minibuffer, to what…

Name
- 7,689
- 4
- 38
- 84
7
votes
3 answers
How to make a dot match a newline
Often I need to use regular expressions to match strings across multiple lines. In python and other languages, it's possible to ask that dots match newlines (as opposed to the default behavior). Is it possible to do this using the default regexp…

erjoalgo
- 853
- 1
- 5
- 18
6
votes
1 answer
setq require-final-newline not working when setq-default does
I want all my files to end with only one newline, while trimming trailing whitespaces on regular lines.
Like so : ($ is newline face)
text$
$
last_line$
I use whitespace-cleanup in my init file, like so :
(add-hook 'before-save-hook…

John Doe
- 159
- 6
6
votes
3 answers
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 have it work. You can do C-u 1 0 M-x newline and get…

William Everett
- 195
- 7
5
votes
1 answer
How to remove empty lines of a selected region of code in Emacs?
Is there a way to remove blank lines from a region of code I select?
I am asking because I copy/pasted code and it seems to have several blank lines I want to get rid off.

Billal Begueradj
- 345
- 1
- 5
- 18
4
votes
6 answers
Search for "foo bar" ignoring comments and newlines
How do I search for "foo bar" ignoring comments and newlines in emacs? For example, given the tex file fragment
blah blah foo % comment 1
% comment 2
bar blah blah
I'd like to be able to type "foo bar" at the emacs search prompt and have my cursor…

Dominic
- 141
- 3
4
votes
2 answers
How to set default encoding to utf-8, and default line ending to linux style?
I use this piece of code to set the default line ending to linux-style \n
;; https://www.emacswiki.org/emacs/EndOfLineTips
(add-hook 'find-file-hook 'find-file-check-line-endings)
(defun dos-file-endings-p ()
(string-match "dos" (symbol-name…

puppon -su
- 43
- 1
- 3
4
votes
1 answer
Customize newline-and-indent function
I'd like to extends this function to work as usual in most cases but if current line starts with * then it should indent and then insert *. Particularly i want to use it in multi line comments, i.e:
/**
* multiline comment
*/
So when i press…

4lex1v
- 603
- 3
- 12
4
votes
2 answers
Make the cursor stop at the last character of a line instead of the newline character
How to make cursor stop at the last character of a line instead of at the linefeed character? I use evil-mode.
Steps to reproduce the issue:
Start Emacs in shell via emacs -nw -Q.
Press C-e to move focus to the end of the line.
You can see the…

chen bin
- 4,781
- 18
- 36