Skip to main content

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.

Filter by
Sorted by
Tagged with
2 votes
1 answer
136 views

can show-trailing-white-space be forced to ignore blank lines

I'm trying to use the flag show-trailing-white-space and it usually shows me what I want. I.e., I never want dangling white space at the end of a line containing text. However, between lines of text,...
1 vote
1 answer
167 views

Delete trailing whitespace on save, but only for yaml files

I would like to run delete-trailing-whitespace for files with extension .yaml only. Can someone please supply the elisp to do this?
0 votes
2 answers
127 views

How can I remove whitespace in HTML?

I would like to be able to go from this: <label for="exampleInputEmail1" class="form-label">Phone number</label> <input type="text" class="form-...
2 votes
1 answer
203 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? ...
2 votes
1 answer
1k views

How can I display tabs and spaces in Doom Emacs?

I have tried M-x whitespace-mode but it does not do anything.
0 votes
1 answer
66 views

Magit `zz` (stash both) does not allow whitespace in minibuffer

Sometimes when using command zz (stash both), the minibuffer to enter a stash message does not allow me to enter whitespace (e.g. space chars). I typically resolve to use dashes or underscores or even ...
0 votes
0 answers
14 views

Delete trailing whitespace only in code chunks in markdown

I dislike trailing whitespace, so I have emacs remove trailing whitespace at every file-save. Unfortunately, in markdown trailing whitespaces are part of the syntax, as markdown uses two trailing ...
9 votes
4 answers
2k views

How to delete all whitespace up to the first non-whitespace character?

I'm looking for an emacs function that will delete all whitespace from the cursor position (including newlines) until the first non-whitespace character. For example, if my cursor is positioned at ...
0 votes
1 answer
39 views

Turn off show-trailing-whitespace in Echo Area

When I run (setq-default show-trailing-whitespace t) on startup, the Echo Area is affected. I can usually turn this off with hooks, e.g. (add-hook 'minibuffer-setup-hook (lambda () (setq show-...
1 vote
2 answers
382 views

Whitespace mode settings on per major mode basis

When I open the Linux Kernel code, my default indentation conflicts with the desired formatting of the Kernel. I use Emacs Prelude, so I added the settings from this link to my c-mode-common-hook. I ...
0 votes
1 answer
92 views

Change white-space color

I'm trying to set the whitespace color with something less visible, but for some reason is not applying it. (custom-set-faces '(whitespace-space ((t (:background "red"))))) this inside ...
0 votes
0 answers
31 views

How do I trim spaces and indentations after traversing a DOM tree?

The following traverse the dom tree and provide an iterative custom formatting. However during the formatting, there are empty spaces and indentations which I needed to trim. ;;; This is where the ...
0 votes
0 answers
57 views

Doom(?) Emacs: whitespace-mode uses incorrect style in c-mode?

I'd like emacs to display tab-marks nicely in c mode: here's an example of how it displays tabs in my config.el, which is how I want it to display tabs everywhere. You can see the nice > ...
-2 votes
1 answer
46 views

function returning space

I would like to have a function that gives me spaces according to a number i multiplied by a factor f. So I end up with returning 6 spaces with (spaces 3 2). This is to be able to indent some ...
0 votes
0 answers
22 views

Prevent deletion of blank lines when tangling code blocks

The Python style guide asks for two blank lines surrounding class and function definitions (see PEP 8). When those blank lines are added in Org-Mode source blocks, they are removed during tangling. ...
0 votes
1 answer
164 views

When I type the tab key, I want a tab, and when I type the whitespace key, I want a whitespace. How can I ensure that?

In the fundamental mode, when I type the tab key, sometimes I got a tab and sometimes 4(?) whitespaces. When does which happen? When I type the tab key, I want a tab, and when I type the whitespace ...
0 votes
2 answers
78 views

How to remove margin space from multiple paragraphs simultaneously in orgmode

Sometimes when copypasting from the web, orgmode retains the margin in the text. Is there a command in Emacs to remove it? I know of cycle-spacing, but this is slow as it works line by line. Is there ...
6 votes
1 answer
796 views

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

Why the number of spaces inserted by M-; is less than the number of spaces in comment-start and comment-padding?

I am using emacs -q and editing a text buffer foo.txt. I have added the following settings: (setq comment-start ">::") (setq comment-padding ":::<") Now if I select a region ...
0 votes
1 answer
65 views

Emacs spacing format is inconsistent with my setup

emacs version: GNU Emacs 26.3 using specman_mode.el most of the company uses gvim, i am using emacs, so the alignment are a bit different. but, when i open the file with emacs -Q, the alignment is ...
11 votes
3 answers
4k views

What's the idiomatic (or best) way to trim surrounding whitespace from a string?

I'm working with strings which may have any number of prefix and suffix spaces, tabs, newlines, etc. Currently I have this: (replace-regexp-in-string "^[^[:alnum:]]*\\(.*\\)[^[:alnum:]]*$" "\\1" ...
7 votes
2 answers
339 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-...
1 vote
1 answer
49 views

How to remove the whitespace on the beginning of every expression on this Clojure code snippet?

I have the following Clojure code snippet: { :id "SchK-Cash-contributions-(60%)" :description "Schedule K - Cash contributions (60%)" :line "L12a" :ultratax-...
2 votes
1 answer
88 views

Trim trailing whitespace upon leaving a modified line

I once had emacs trim trailing whitespace upon leaving a line, if that line had been modified. Note: I already have trim at save, it is not what I am asking for here. I have the package ws-butler, but ...
4 votes
2 answers
1k 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
1 answer
73 views

Is there an inbuilt function on Emacs to change all two or more consecutive spaces into one in Emacs?

Basically that: would like to find an easy way to convert all those consecutive blank spaces into one in Emacs. Thanks for your help. This: text text text text text text text Into this: text ...
1 vote
1 answer
342 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] [...
2 votes
1 answer
49 views

How can I make isearch match phrases across line breaks?

Suppose I have a text document (e.g. org-mode, Markdown, etc.) in which I would like to search for the phrase "hello world". Unfortunately, if paragraphs in this document are filled (e.g. ...
1 vote
1 answer
35 views

Can replace-regexp-lax-whitespace manage "~" as a whitespace?

I have this function: (defvar biblio-publishers-info-list '(("Cambridge University Press" . "Cambridge, U.K.")) "DOCSTRING") (defun biblio-publishers-info-complete ()...
29 votes
3 answers
4k views

Match two spaces with incremental search

When searching using: C-s SPC SPC Also matches single spaces. I want to match exactly two space.
18 votes
7 answers
6k views

Easiest way to check if current line is "empty" (ignoring whitespace)?

I just want to check if the current line is empty or not (if it contains only whitespace, then I still consider it empty). Here is my initial version: (defun strip-text-properties(txt) (set-text-...
1 vote
1 answer
112 views

searching for explicit spaces, without reinterpretation

Often I'll search (an ordinary i-search) for a sequence of two spaces, or three, or four. But on one machine I'm using, emacs by default appears to be in some mode where searches for spaces are ...
1 vote
0 answers
71 views

diff-mode: how to highlight whitespace characters?

with emacs -Q, I can use M-x whitespace-mode : But in diff-mode, if I use M-x whitespace-mode this is what I get: you can see the tabs/space/newlines aren't shown (highlighted). How can I make diff-...
6 votes
2 answers
975 views

Whitespace-mode tab mark disturb my indentation

I encounter this issue when i set whitespace-style to (face tabs trailing tab-mark) and turn on whitespace-mode. When whitespace-mode is turned off, everything looks well: When whitespace-mode is ...
6 votes
1 answer
1k 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 ...
3 votes
1 answer
286 views

show white spaces only when region is selected

whitespace-mode will show the whitespace all the time in entire buffer, Is there the way to show whitespaces only when the region is selected. which is pretty cool to have, does there mode exist for ...
1 vote
1 answer
54 views

Leaving only one space between words within a paragraph

I have read https://www.emacswiki.org/emacs/DeletingWhitespace but couldn't find a way to select a paragraph and remove extra white spaces. For instance: asd asdasd asdasd asdasdasd asdasda ...
0 votes
0 answers
35 views

I want to make an alias to `org-babel-execute:emacs lisp`. the problem is with the space on `emacs lisp`

I'm using org-beamer exporter, and I would like to do the following: (defalias 'org-babel-execute:emacs-lisp lisp 'org-babel-execute:emacs lisp) My problem is 'org-babel-execute:emacs lisp has a ...
1 vote
1 answer
93 views

How to search for words separated by arbitrary whitespace?

The question is general, but here's a specific case: In LaTeX source files, it doesn't matter if two words are separated by one space character, multiple space characters, or even a linebreak - in the ...
2 votes
2 answers
78 views

Temporarily restrict editing to whitespace only

Sometimes I make whitespace cleanups to source code. I'd like to be certain that I do not accidentally introduce real code changes (let us assume that the programming language is one where removing ...
0 votes
1 answer
125 views

Why Emacs creates multiples whitespaces after I create a comment and jump to a new line?

I am using Emacs, Paredit, Slime to work on Common Lisp (SBCL). When I create a comment such as: ; test It is placed as expected. But if I press return in order to create a new line below ;test this ...
1 vote
1 answer
159 views

What are these underlines shown for whitespace at the end of some lines?

The following screenshot shows Emacs 26.3 (GNU Emacs 26.3 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.14) of 2020-03-26, modified by Debian) editing a Markdown file: Note that on some lines of ...
4 votes
3 answers
2k views

Disable removal of trailing whitespace in Emacs

I'm using Emacs 25.1.50 (9.0) on OS X and am starting to get annoyed with the automatic removal of trailing whitespace. I have tried solutions from here, but to no avail as my write-file-functions and ...
1 vote
1 answer
119 views

whitespace-style "face" activates highlighting of quoted string in fundamental mode

After putting face to whitespace-style: (setq whitespace-style '(trailing tabs empty face)) (global-whitespace-mode 1) string enclosed in a double quote started to be highlighted by font-lock-string-...
0 votes
1 answer
75 views

Spacemacs, Lisp, Pasting and the missing Space

When editing Lisp or Clojure in Spacemacs (Emacs with Evil) I find the pasting behavior anoying. Say I have yanked bar and want to paste it as a parameter to (foo) so I get (foo bar). The problem is, ...
0 votes
1 answer
161 views

Hitting Return at start of line deletes leading whitespace. How to I prevent this?

If I have a line of text in a file with leading whitespace, and I move to the beginning of that line and hit enter, the whitespace is deleted such that the first non-whitespace character is the first ...
0 votes
0 answers
286 views

How can I disable line numbers on empty lines?

I find it easier to visualize double line breaks if there's actually blank space between paragraphs. I never need to see the line number of a blank line, but I do really like seeing a line number when ...
0 votes
0 answers
1k views

Make tabs behavior like in other IDEs

How can I force Emacs to use tab button and TAB character in "normal stupid way"[1], like in nano or VScode or JetBrain's IDEs. All I can find is smart-tabs package and indent-tabs-mode, but ...
12 votes
2 answers
1k views

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, ...
4 votes
1 answer
143 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 ...