Questions tagged [newlines]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
41
votes
2answers
20k views

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?
40
votes
4answers
22k views

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 ...
11
votes
2answers
11k views

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 ...
11
votes
2answers
716 views

How can I suppress emacs' display of the final newline in 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, ...
6
votes
2answers
22k views

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 ...
6
votes
3answers
738 views

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 ...
5
votes
2answers
2k views

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 ...
5
votes
1answer
2k views

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-...
4
votes
2answers
1k views

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 ...
4
votes
1answer
9k views

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 ...
4
votes
6answers
282 views

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 ...
4
votes
1answer
353 views

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: /...
3
votes
1answer
213 views

Bind C-e C-j and C-a C-o TAB to single key, aka insert and jump to newline

C-e C-j will insert a newline below and jump to it indented. C-a C-o TAB will insert a newline above and jump to it indented. Is there a single bind to these or where/how should I bind these commands?...
3
votes
1answer
256 views

Make `return` key more powerful

Normally return key is just newline, I believe a lot of people bind it to newline-and-indent, but return is relatively common used key, the C-u RET and C-- RET basically do nothing but same as return, ...
3
votes
2answers
346 views

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

I code in Erlang, and I dislike the default indentation style that erlang.el provides: it tends to push code way too far to the right for my likings. I'd like to have a simple automatic indentation ...
3
votes
0answers
409 views

How to delete all white space during save except for final new line

I am aware that it is a good idea to have one blank line at the end of each file. I am also aware that extra white space in a file is bad. Currently in my .emacs file I have (add-hook 'before-save-...
2
votes
1answer
38 views

Specify the number of blank lines

Upon leaving multiple blank lines (saying 4 lines of blanks), I have to strike four times of Enter. Tried C-u Enter or C-3 Enter, it does not work. How could specify the number lines like C-3 space?
2
votes
2answers
1k views

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-...
2
votes
1answer
229 views

Tramp file encoding for Unix

I have managed to setup Tramp to connect to a remote Solaris machine from a Windows machine using plink, which is very nice. (setq tramp-default-user "Beginner" tramp-default-host "the_host" ...
2
votes
2answers
32 views

Define key binding for a single mode (Fundamental)

In light that this may be a duplicate, but I did not find the answer to my question scouring this site. The default behavior of GNU Emacs appears to have electric-indent-mode enabled, which is fine ...
2
votes
1answer
80 views

Search and replace two consecutive newlines

Running spacemacs 0.200. I am sorry if it is too basic. But I am just not able to get this. How do I convert two consecutive newlines with some text, say, 'there were two newlines here'? I could ...
2
votes
1answer
202 views

Weird spacing with whitespace newline mark “↴” [duplicate]

I have my whitespace newline mark set to the "↴" character, (setq whitespace-display-mappings '( (newline-mark 10 [8628 10]) ))...
1
vote
1answer
123 views

Imitate paragraph spacing in visual line mode

I write long texts using org-mode and visual-line-mode. Each long line, wrapping over several visual lines, looks like a "paragraph", and behaves similarly to a paragraph in a traditional word ...
1
vote
1answer
757 views

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.
1
vote
1answer
535 views

Emacs whitespace mode doesn't show ^M characters

Somebody in my team has checked in a file with MS-DOS line endings into the git repo. with vi's binary mode, vi -b hello.py, i can see lines ending with ctrl character - ^M. In emacs, whitespace-...
1
vote
1answer
110 views

Previous indentation is discarded on newline

Let's say I have the following code: void foo(){ ~ } I have marked point with ~. When I press enter the electric indentation works as normal but it doesn't keep the indentation for the previous ...
1
vote
1answer
138 views

How to improve the `M-! command` output

I found this really cool in emacs M-! t t is ~/bin/t, and runs tests for whatever thing I'm working on. I added ~/bin/ to my /etc/path.d/, and I always use emacs -nw. My issue is, the command ...
1
vote
4answers
437 views

Recursively insert a new line character in every line at a certain column

I was just going to ask how to accomplish this, but through a few DuckDuckGo searches, I was able to answer a lot of my question. I have a buffer of part numbers and part number descriptions each in a ...
1
vote
1answer
440 views

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

*Edit* fci is no longer supported, emacs-27 supports this feature natively. The are various known bugs with the fill-column indicator, there is one well known bug that occurs when the window is too ...
1
vote
0answers
107 views

Auto-indent problems related to syntax in Haxe-Mode

In the Haxe programming language, you can specify the type of the return value of a function with a colon. function funcName() : ReturnType { } This becomes a problem when using emacs with haxe-mode....
0
votes
1answer
588 views

elisp regex newline escape confusion

Shown below is a simple function, which was run in the middle of a text file that contained multiple instances of repeated blank lines. The output of the function is also shown below. The only ...
0
votes
1answer
227 views

How to get rid of the red areas and what are they?

I have some code I copy-paste from somewhere. What is this how to get rid of them all at once? My emacs is setup to automatically cut the orange areas, but to get rid of these? update: ...
0
votes
0answers
7 views

What does “Automatic selection from [utf-8-unix utf-8-dos utf-8-mac]” mean in description of utf-8 coding system?

I'd like all new files created by Emacs (28.0.50 prerelease on Win10) to have Unix-style (LF) line endings by default. I've had the following in my .emacs for a long time: (prefer-coding-system 'utf-...
0
votes
1answer
25 views

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

Is there a convenient way to count the number of lines between two points? While I could search for \n in a loop and limit it to one of the points, this seems like an overly verbose way of doing it.
0
votes
0answers
21 views

When I click on a file on the spacemacs start screen, it automatically enters a newline

This only happens when I open a file with a mouseclick on the spacemacs start-screen. Very odd, it does not even work when I press enter instead or when I open the file in another way. The reason ...
0
votes
0answers
81 views

Changing the definition of the paragraph

I would like to change the definition of the paragraph in such a way that every line to be considered as a paragraph. As I understand from the documentation, one should change the variables paragraph-...
-1
votes
1answer
150 views

How to find all characters, newlines included?

I have this LaTeX code: %%% 10 \bibitem{bib2} W.~Kockelmann, G.~Burca, J.F.~Kelleher, S.~Kabra, S.-Y.~Zhang, N.J.~Rhodes et~al., \emph{Status of the neutron imaging and diffraction instrument IMAT},...
-1
votes
1answer
418 views

yasnippet doesn't recognize $0 placeholder, why?

My emacs is running on Window 7 and I have just installed yasnippet via M-x package-list and added few lines to my .emacs file because I read around the web that it needs to be initialized. I tried ...