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
0 votes
1 answer
42 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 ...
Math's user avatar
  • 101
0 votes
0 answers
29 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 ...
alexander's user avatar
  • 133
0 votes
1 answer
26 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-...
faulty_ram_sticks's user avatar
0 votes
0 answers
38 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 > ...
user41268's user avatar
-2 votes
1 answer
44 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 ...
Dilna's user avatar
  • 1
0 votes
0 answers
20 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. ...
Ben Bkhdt's user avatar
0 votes
1 answer
110 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 ...
Tim's user avatar
  • 4,987
2 votes
1 answer
45 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 ...
Lone Learner's user avatar
0 votes
1 answer
53 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 ...
Michael Marjieh's user avatar
0 votes
1 answer
57 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 ...
Harald's user avatar
  • 220
1 vote
1 answer
46 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-...
Pedro Delfino's user avatar
2 votes
1 answer
73 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 ...
Gauthier's user avatar
  • 499
0 votes
2 answers
72 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 ...
Adelita's user avatar
  • 155
0 votes
1 answer
58 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 ...
Emmanuel Goldstein's user avatar
2 votes
1 answer
43 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. ...
Ryan C. Thompson's user avatar
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 ()...
Gabriele Nicolardi's user avatar
1 vote
1 answer
78 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 ...
Steve Summit's user avatar
2 votes
1 answer
972 views

How can I display tabs and spaces in Doom Emacs?

I have tried M-x whitespace-mode but it does not do anything.
BigBoy1337's user avatar
1 vote
0 answers
66 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-...
John Doe's user avatar
  • 169
1 vote
1 answer
43 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 ...
Emmanuel Goldstein's user avatar
0 votes
0 answers
34 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 ...
BuddhiLW's user avatar
  • 267
1 vote
1 answer
86 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 ...
felix's user avatar
  • 153
0 votes
1 answer
59 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 ...
Pedro Delfino's user avatar
6 votes
1 answer
710 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 ...
John Doe's user avatar
  • 169
0 votes
2 answers
108 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-...
simone's user avatar
  • 101
1 vote
1 answer
134 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 ...
Cactus's user avatar
  • 165
1 vote
1 answer
111 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-...
gavenkoa's user avatar
  • 3,362
0 votes
1 answer
71 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, ...
Witek's user avatar
  • 335
0 votes
1 answer
144 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 ...
Jeff S's user avatar
  • 1
0 votes
0 answers
273 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 ...
Oliver Richardson's user avatar
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 ...
superpupervlad's user avatar
0 votes
1 answer
73 views

Make org-delete-char (C-d) delete extra space after deleted word

Hitting C-d (org-delete-char) in an Emacs org file deletes the word following the cursor. I would like to delete the extra space left also without having to use DEL. I.e. one action to delete word and ...
Edman's user avatar
  • 1,167
2 votes
1 answer
112 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,...
Jim Newton's user avatar
2 votes
0 answers
480 views

How to display only leading spaces in whitespace mode

I've been having trouble getting whitespace to visualize properly. Specifically for 'spaces' I'd like to only display leading spaces, but turning on space white space visualization includes all spaces,...
Justen Martin's user avatar
0 votes
0 answers
29 views

All of a sudden i started seeing an insertion of a period after two spaces, even in programming mode files

I started noticing this after an update, every two spaces at end of a word/symbol places a period at the end. I am not sure how to debug this or where to look. any pointers appreciated.
SFbay007's user avatar
  • 554
1 vote
0 answers
196 views

Preserving the space immediately after an org heading when deleting trailing whitespace

I use a hook to delete trailing whitespace on saving files: (use-package emacs :hook (before-save . delete-trailing-whitespace)) This works well in 99% of cases. However, if I am trying to create ...
Edman's user avatar
  • 1,167
1 vote
0 answers
74 views

Add whitespace as indentation with `indent-region`

When using indent-region, emacs will indent code and leave bank spaces untouched. It seems to me that the majority prefer to delete whitespace. However I prefer white space indented with the code. An ...
HubCo's user avatar
  • 11
2 votes
1 answer
248 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 ...
rho's user avatar
  • 243
1 vote
1 answer
353 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 ...
yujaiyu's user avatar
  • 896
0 votes
2 answers
985 views

How to add some space to the left of the line numbers in linum-mode?

When I enable linum-mode in the scratch buffer (and most other buffers I tried) there is no space to the left of the line numbers. Although when enable linum-mode in the .emacs configuration file, I ...
scribe's user avatar
  • 980
2 votes
1 answer
714 views

Insert space but don't move point

Search didn't yield any success. Perhaps I'm using the wrong search terms... I'd like to insert a single space (just like when you hit SPC) but without changing point. I come up with an example (let |...
rudolfo.christ's user avatar
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 ...
Ed Avis's user avatar
  • 151
4 votes
1 answer
948 views

Is [:space:] same as \s-?

Emacs 26.1 In regexp help https://www.emacswiki.org/emacs/RegularExpression has the next regexp: [:space:] a whitespace character Is this a same as: [ \t\r\n\v\f] and same as \s- ?
a_subscriber's user avatar
  • 3,906
3 votes
1 answer
1k views

How do you type a space character in Spacemacs?

I was researching editors and I ended up stumbling upon Spacemacs and the fact that it uses the spacebar instead of traditional modifier keys. The documentation claims that this lowers the user's risk ...
Ryan1729's user avatar
  • 133
0 votes
1 answer
58 views

automatic indentation with space like visual studio

Is there any package that covers indentation with space like visual studio? like, if(a==b) ==> if(a<space>==<space>b) for(int i=0;i<N;i++) ==> for(int i<space>=<space&...
edward0im's user avatar
  • 199
1 vote
0 answers
72 views

How can I split LaTeX inline math from preceeding or following sticked words?

I have this LaTeX code: Lorem $math$ ipsum $math$dolor sit consecteruer adipscing elit, sed do eiusmod tempor incidunt ut labore et dolore magna aliqua. $math$Ut $math$ enim ad minim veniam$math$, ...
Onner Irotsab's user avatar
4 votes
1 answer
1k views

How to stop Emacs from deleting trailing whitespace?

By default, Emacs quietly deletes trailing whitespaces once the user moves on to the next line. To reproduce the issue in plain Emacs, do this: Start plain Emacs: emacs --no-init-file --no-site-file ...
Flux's user avatar
  • 593
10 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" ...
user23847's user avatar
  • 101
0 votes
1 answer
32 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:
a_subscriber's user avatar
  • 3,906
2 votes
1 answer
779 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, ...
oneself's user avatar
  • 301