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
1 vote
1 answer
122 views

How can I control the indentation inserted by Emacs because I used the tab key?

This is probably a really basic question, but something I hadn't thought about before: When editing code, how to indent? I think the way to go is simply use the tab key and then, once indented once, ...
arcomber's user avatar
  • 219
0 votes
0 answers
26 views

How to get rid of dots for space characters (buffer-display-table)

I'm seeing space characters in typescript-tsx-mode (tree-sitter, emacs 29) rendered as the "middle dot" unicode character: ·. The dots show up even when the space characters are at the ...
Croad Langshan's user avatar
1 vote
1 answer
189 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?
Brian G. Marete's user avatar
0 votes
0 answers
48 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 ...
Andreas's user avatar
  • 101
0 votes
1 answer
130 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
  • 103
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 ...
alexander's user avatar
  • 133
0 votes
1 answer
44 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
72 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
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 ...
Dilna's user avatar
  • 1
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. ...
Ben Bkhdt's user avatar
0 votes
1 answer
177 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
  • 5,027
2 votes
1 answer
48 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
70 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
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 ...
Harald's user avatar
  • 328
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-...
Pedro Delfino's user avatar
2 votes
1 answer
102 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
  • 511
0 votes
2 answers
81 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
  • 255
0 votes
1 answer
85 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
52 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's user avatar
  • 1,660
1 vote
1 answer
144 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
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.
BigBoy1337's user avatar
1 vote
0 answers
75 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
59 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
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 ...
BuddhiLW's user avatar
  • 297
1 vote
1 answer
96 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
149 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
840 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
167 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
170 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
121 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,472
0 votes
1 answer
77 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
  • 375
0 votes
1 answer
166 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
295 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
87 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,229
2 votes
1 answer
149 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
572 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
45 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
  • 584
1 vote
0 answers
215 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,229
1 vote
0 answers
78 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
3 votes
1 answer
307 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
  • 253
2 votes
2 answers
398 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
  • 906
0 votes
2 answers
1k 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
  • 1,045
2 votes
1 answer
833 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
80 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
1k 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
  • 4,174
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
62 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&...
gyubeomim's user avatar
  • 199
1 vote
0 answers
81 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