Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

1
vote
3answers
39 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
33 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 ...
0
votes
1answer
29 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? ...
0
votes
1answer
30 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
37 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
45 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
0answers
48 views

org-mode / export to PDF / how to preserve consecutive spaces

When I export a simple text file to PDF with the command org-latex-export-to-pdf, by default, org-mode converts consecutive white spaces into a single white space. For example the text: " / / ...
0
votes
0answers
76 views

Indentation Error when running Ipython shell (emacs/spacemacs, Windows)

I am a relatively new to emacs/spacemacs and my knowledge is quite basic, I have spacemacs set up with the python layer and have the indentation settings as follows: python-indent-offset is set to 4 ...
0
votes
1answer
37 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
42 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 ...
0
votes
0answers
40 views

Highlight 'codespace' to prevent long lines

As it's often useful to highlight when a line of code exceeds a certain number of columns, I have cobbled together a function which allows me to toggle on/off whitespace mode: (setq-default ...
3
votes
0answers
39 views

Emacs automatically insert spaces to format source-code

In Visual Studio, there is a setting column, where you can tell VS to (e.g.) insert space after comma insert space after semicolon insert space before and after binary operators insert space around ...
0
votes
1answer
65 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
80 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
32 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
91 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
119 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 ....
6
votes
2answers
70 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
87 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
21 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
213 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
139 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
65 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/...
2
votes
1answer
111 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' ...
1
vote
0answers
81 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
67 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
50 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
689 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
59 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
90 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
32 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?
1
vote
2answers
346 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
96 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 ...
0
votes
1answer
509 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
53 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] [...
7
votes
0answers
268 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
75 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
34 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
69 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
80 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 ...
3
votes
0answers
40 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
37 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
100 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
31 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
200 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 ...
0
votes
1answer
123 views

modify tab length for eclim-java-format

So I'm trying to use eclim with spacemacs and I have this function called eclim-java-format which reformat the text as in eclipse. The problems is that it reformats tabs as tabs and not as space and ...
1
vote
1answer
73 views

Ignoring newline changes in smerge-diff-mine-other

For me, smerge-diff-mine-other seems to ignore changes in the number of whitespace characters where there is whitespace, but I would sometimes like it to ignore all whitespace, including newlines - ...
4
votes
2answers
151 views

Delete trailing white space from all projectile project files

Problem So the problem is pretty straight forward I'm just trying to get delete trailing spaces from all files in a projectile project. Here's what I've tried so far: (defun projectile-delete-...
2
votes
0answers
41 views

Are there any packages or configuration snippets for better whitespace traversal?

Whitespace traversal in Emacs is atrocious. By "traversal" I mean: Moving the point with C-<direction> Expanding a selection (with either a package or region mark) Deleting with C- or M- ...
2
votes
1answer
224 views

Difficulty with query-replace-regexp

I'm having trouble getting query-regex-replace to do what I want. I've read the docs several times and still can't figure it out. Here are a few examples of things I can't figure out how to do with ...