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
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

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
2answers
30 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
25 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: " / / ...
-1
votes
0answers
44 views

from emacs to SE

My question is simple : "how to properly use emacs to feed text area'SE with code?" For now, I select in the buffer with the mouse my code and paste it (Button-2) into the present zone, e.g : 1 │ ...
0
votes
0answers
57 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
24 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
34 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
32 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
33 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
45 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
78 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
23 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
89 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
116 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
62 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
1answer
73 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
179 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
102 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
62 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
95 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
61 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
64 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
46 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
530 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
58 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
70 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
30 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
313 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
84 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
289 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
45 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
215 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
68 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
58 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
73 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
39 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
36 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
97 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
27 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
186 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
109 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
67 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
136 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
184 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 ...
3
votes
1answer
52 views

Function to allow select a directory and run a command on its files, descending recursively?

I sometimes work on legacy code, and they have mixture of tabs and spaces. I use whitespace-cleanup function in whitespace.el to clean them up. But I have many files, so i want to run the command on ...
1
vote
1answer
108 views

Virtual space for rectangular selections (at least)

In Vim there is the virtualedit variable which can be set so that Vim allows the cursor to move past the end of the line always or only when in visual block mode. Is it possible to configure Emacs to ...
1
vote
0answers
33 views

Increase spacing between physical lines only

How can I add spacing where there are linebreaks in the file, but not where a line is word-wrapped? This would be very useful for reading log files with long lines. Here's a mockup of what I'm after: ...
1
vote
3answers
59 views

How can I switch whitespace-mode enabled/disabled by key?

(defun switch-whitespace-mode () (interactive) (whitespace-mode) ) (global-set-key (kbd "<f6>") 'switch-whitespace-mode) Through the above configuration,I failed.