Questions tagged [whitespace]

for questions about handling white or blank spaces. Besides space characters, Emacs is configured to handle the following as white space characters: tabs, indents, newlines that create blank space between text, either horizontally or vertically.

0
votes
1answer
22 views

Can't mark only spaces

I want to select by regexp only spaces. Here text: test-hello how-are again ok maybe good but-some not good I use regexp [:space:] but it's not work:
1
vote
1answer
31 views

delete-trailing-whitespace on save while always preserving location of cursor

I have the following before save hook defined which deletes all trailing whitespace and converts tabs to spaces (except in makefile mode since makefiles need tabs to work). This works great, however, ...
2
votes
1answer
97 views

Highlight missing double-space between sentences?

For a while, I've been using sentence-end-double-space: nil. Now I want to get back into the habit of using two spaces to separate sentences. It is the convention for GNU documentation, and it ...
0
votes
0answers
8 views

Stop indentation from altering pre-formatted text

.preformatted { white-space: pre-wrap; } <div class="preformatted"> THIS TEXT IS PREFORMATTED <= no spaces there, before pasting this text in this code ; It should render ...
1
vote
2answers
69 views

Avoiding typographic “rivers” with Emacs

When reading manuals in *info* mode, I found rivers somewhat distracting. For example, the left image is what I see on the screen, whereas the right one have some rivers annotated out. (see also Tex....
1
vote
0answers
36 views

How do I end an org capture template with whitespace?

I want to make an org capture template that ends in whitespace. Specifically, I want to make TODOs that are scheduled. From emacs -Q, I'm starting with this template: (cl-pushnew '("T" "TODO ...
2
votes
2answers
50 views

Convert tabs to spaces when copying text to external applications

I use tabs in C/C++ but want to convert those tabs to spaces when copying code that I'm going to paste into an external program. However, I want the original code to retain tabs. Additionally (if ...
0
votes
2answers
170 views

Confusion about space and tab characters in Emacs

I am confused by space (SPC) and TAB characters in Emacs. I am often using the default fundamental mode. When I select a region and indent the lines in the region by C-u 9 C-x TAB, I intend to ...
0
votes
4answers
224 views

How remove whitespaces in the beginning of lines?

Emacs 26.1 I has the next text: I need to remove all whitespaces in the beginning of the lines. Every line has different count of whitespaces. The result must be like this:
1
vote
3answers
229 views

emacs command to remove spaces until next parens

I'm looking for a command that deletes automatically deletes spaces up to the next parens: from: (do | (do-something) true) to: (do |(do-something) true)
3
votes
1answer
48 views

formatting of elisp file is different in emacs and other text editor

I'm having an issue with formatting in that when I'm in emacs, the formatting looks fine: but when the file is viewed with a different text editor, the spaces are different. this only occurs in the ...
1
vote
1answer
46 views

Can I get whitespace-mode to display a sequence of two leading spaces , specially?

Like this: I have been able to get whitespace-mode to display dots for leading spaces. But I want to specially display each sequence of 2 leading spaces, with maybe a vertical bar. Possible? ...
1
vote
1answer
213 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.
0
votes
1answer
144 views

How can I ask emacs to show me (visually) invisible characters like CR LF?

The title says it all: I want emacs to show (all, or only some, like CR LF) invisible characters in my buffer? (If it matters: I am using the latest emacs (25) on the latest debian testing) (I am ...
1
vote
2answers
102 views

Emacs equivalent to :set list in vim

I'm looking for a way to display hidden characters like newline and tab characters in emacs. I am NOT trying to convert the characters, just display them in the current buffer. In vi(m), I can do ...
0
votes
1answer
56 views

How to reveal tabs in the indentation in a cpp file?

My friend and I collaborate on a C++ project and we agree to use 4 whiltespaces for indentation. I am using Emacs and this is my indentation setting (setq-default c-basic-offset 4) By doing this, I ...
1
vote
1answer
80 views

Search forward for the FIRST space character and stop there

I recently upgraded from Windows Emacs 19.x to Windows 26.3.1 and have a problem. in the old version 19 if I did a search forward for a space, (C-s) it skipped forward to the FIRST space character ...
2
votes
1answer
182 views

Delete trailing whitespace when saving, except certain modes

How can I delete-trailing-whitespace when saving, except for certain modes? With this attempt, whitespace is deleted for all modes, including fundamental-mode, which I'm trying to avoid. (add-hook '...
0
votes
2answers
127 views

Highlight useless whitespace at end of file

How do I make Emacs highlight whitespace at EOF, eg. any whitespace after >?\n for PHP? I think the general rule would be: After the last non-whitespace character, accept one newline, then ...
0
votes
1answer
74 views

pressing return in paragraph-indent-text-mode deletes whitespace indenting beginning of paragraph

I'm currently using emacs 25.3 on Mac OSX installed using Homebrew, and without any modifications in my .emacs file or anywhere else. I think I may be fundamentally misunderstanding what paragraph-...
3
votes
1answer
98 views

List modified line numbers in a buffer

Emacs provides a fair few commands (delete-trailing-whitespace, for instance) that can be used to clean up buffers, but sometimes we cannot use them and risk compromising the version history of ...
3
votes
3answers
144 views

magit-status does not open, when using (global-whitespace-mode 1)

This problem started happening today when I switched to my desktop computer after a couple months of using my laptop. I updated emacs to 25.3.1, updated all my packages, and downloaded my latest ....
7
votes
2answers
101 views

Is there a hook that runs for all read only buffers

I want to enable show-trailing-whitespace for editable file and disable show-trailing-whitespace for read only files. I've tried (defun my/read-only-whitespace () (setq-local show-trailing-...
0
votes
2answers
102 views

can I quickly clean up html files with emacs (prelude)

How do you clean up an html file? For example, this file has one too many empty line between the div tags. I would like cleanup to leave only one blank line there. <html> <body> &...
0
votes
1answer
23 views

Space and line-end indicators stay after switching off whitespace-mode

When I switch on whitespace-mode I get all the indicators and color for showing superfluous whitespace. So far so good. But when I switch off whitespace-mode the space indicator . and the line-end ...
2
votes
1answer
342 views

org-mode setting to preserve spacing in SRC code, with verbatim latex output to pdf

Like this post, when I indent within a SRC code block in org-mode, 8 consecutive spaces are converted to a tab. Moreover, when I export to LaTeX 8 consecutive spaces are converted to tabs in the ...
0
votes
2answers
269 views

How to disable show-trailing-whitespace in emacs shell?

I have set show-trailing-whitespace as default in my .emacs file but I don't want it to work on shell and some specific buffer. I can disable it manually every time I open an emacs shell but I want ...
0
votes
2answers
87 views

Function that deletes redundant leading whitespaces of a region while maintaining indentation

Is there a Elisp function that deletes "redundant" leading whitespace of the region while maintaining relative indentation. This behavior is like textwrap.dedent in python. https://docs.python.org/2/...
3
votes
1answer
213 views

Move to goal-column inserting spaces if necessary

I have a bunch of lines of text and I'm trying to insert text starting at a certain column on each line. For example: 'Some text' This is ok 'Another longer text' ask Ram 'weird stuff' ...
2
votes
0answers
157 views

How to display and format leading spaces (spaces at the beginning of a line) with whitespace-mode?

I want to see all spaces at the beginning of a line as dots. Also tabs and line breaks. So I've set my init.el file as the following: (setq-default indent-tabs-mode nil) (setq whitespace-style '(...
2
votes
2answers
79 views

Automatically insert a space in some C expressions

The corporate rules about indention forces us to surround our if conditions with spaces like this (in a C and C++ codebase) : if (<space>foo == bar<space>) { } Is there any emacs tool ...
0
votes
0answers
61 views

What is causing `delete-trailing-whitespace`?

In some buffers (e.g. diff buffers) the trailing whitespace is essential to the format and must be preserved. What is causing Emacs to invoke delete-trailing-whitespace whenever I save the buffer? ...
0
votes
1answer
1k views

Turn off whitespace-mode highlighting

I took the following from this site. (progn ;; Make whitespace-mode with very basic background coloring for whitespaces. ;; http://ergoemacs.org/emacs/whitespace-mode.html (setq whitespace-style ...
0
votes
1answer
66 views

how to fixup line breaks?

I'm looking for a command that behaves similiar to fixup-whitespace, but I want it to also remove line breaks between objects around point.
1
vote
1answer
129 views

How to trim whitespace from the end of a multi-line string?

It seems subr-x's string-trim-right only operates on the last line. How to strip trailing spaces on all lines in a variable?
1
vote
1answer
39 views

How to call (line-end-position) that returns a value excluding trailing whitespace?

What is a good way to replace (line-end-position) with a function that doesn't include trailing whitespace?
2
votes
2answers
489 views

css-mode: use tabs and not spaces

How do I make it so tabs are used instead of spaces when TAB is pressed? I've tried setting indent-tabs-mode to t but no dice. On my other modes, such as php-mode and c-mode, tabs are inserted. CSS ...
1
vote
0answers
143 views

How to get hungry-delete working in paredit-mode?

Using hungry-delete is really nice, see this Blog post. But with paredit activated, hungry-delete functions are not triggered. paredit defines <delete> as paredit-forward-delete and DEL as ...
1
vote
1answer
1k views

Is there a function for removing trailing spaces in a buffer?

Does emacs have a built in function for removing trailing spaces in a buffer? I want to remove trailing whitespace at the end of all the lines in a buffer.
0
votes
0answers
108 views

Possible to modify 'whitespace-display-mappings' at runtime?

Making changes to whitespace-display-mappings while emacs runs doesn't seem to do anything. (setq whitespace-display-mappings '( (space-mark 32 [183] [46]) ; middle-dot (tab-mark 9 [9654 9] [...
6
votes
0answers
387 views

Display tab characters as arrows of varying length

I would like to make tab characters ("\t") display as arrows of varying length, just like in editors such as Notepad++, gedit, Geany, etc. Here is an example with tab width set to 4 and space ...
1
vote
1answer
93 views

Match blank lines at end of file

How can I match – in, for example, a group of files from a Dired buffer – all files that have one or more blank lines at the end of the file? The specific need that prompts this question is to remove ...
0
votes
1answer
39 views

Changed indentation settings - how to reformat old code?

I changed my Emacs configuration including indentation settings -now when I open an old C++ file I can write code and it looks like this: int x(int z){ return z; } However, the old code in this ...
1
vote
2answers
146 views

delete trailing new lines / whitespace, but not an image at eob

I have a buffer that will have either plain text or an image (text properties) near the end of the buffer. I would like to delete any new lines or whitespace at the end of the buffer. How can I do ...
2
votes
0answers
104 views

How can I define `search-whitespace-regexp` so it accepts a Unicode “no-break space”?

I'm writing a lot of Markdown for input to pandoc, so my files contain a lot of Unicode non-breaking spaces (U+00A0). I'd like those to search as whitespace with isearch-forward, so I tried adding ...
2
votes
0answers
42 views

Auto-indenting C code with tabs for blocks and spaces for other wrapping? [duplicate]

Is it possible to setup emacs to indent C code, with tabs for blocks { ... } and spaces with other wrapping (argument, for example)? Eg: <-->if (foo) { <--><-->function(a, b, <--...
0
votes
1answer
40 views

How to account for tabs in `hl-line-range-function`?

To avoid conflicts with highlighting indentation, I made the highlight line begin after the current indentation. This works well, except when tabs are used as leading white space. How could the my-...
7
votes
2answers
112 views

How to highlight preceeding space-indentation that isn't rounded to current width?

Is there a way to highlight (set the background color for example) the space before a line, when it's indentation isn't aligned to the current indentation-width? 4 spaces indentation for eg: fn ...
1
vote
0answers
55 views

auto-fill-mode fails in comment with empty second line

Consider the following comments: ;; This is the first line of a comment. ;; ;; This is the second line, which begins a paragraph. If I have ;;auto-fill-mode enabled, I lose the leading space! ;; ...
5
votes
1answer
251 views

avoiding underlined spaces between two lines

It must be very simple to get rid of but I could not find something addressing the problem : I would like to avoid underlined spaces between two lines. The following screenshot illustrates the problem ...