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.

Emacs provides extensive editing, parsing, printing, and programming support for handling white spaces. The in one such feature, which has consolidated blank-mode and many other space functions.

Emacs can clean up spurious characters in buffers without clobbering spacing needs of the underlying programming language syntax.

Emacs also uses the same definitions for determining boundaries between words, sentences, expression, etc., for text selections, insertions, deletions, and general navigation.

Some functions insert customizable visual characters for easy visibility.

Useful link:

147 questions
43
votes
5 answers

How to shift a selected area of text in Emacs by a certain number of spaces?

I am writing python code so shifting/moving blocks of lines is important to avoid going through each line individually. How can I do this without an add-on? Is there a type of operation keystroke command to do this?
Vass
  • 723
  • 1
  • 5
  • 13
18
votes
7 answers

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-properties 0 (length txt) nil txt) txt) (defun…
Chillar Anand
  • 4,102
  • 1
  • 24
  • 52
12
votes
1 answer

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.
vfclists
  • 1,403
  • 1
  • 12
  • 28
9
votes
2 answers

How can I visualize trailing whitespace like this?

I've tried to configure whitespace-mode to do what I want but with no luck. I'm trying to achieve the following (see image).
Cezar
  • 193
  • 1
  • 7
8
votes
3 answers

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)
zcaudate
  • 647
  • 4
  • 14
4
votes
3 answers

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 before-save-hook variables are nil to begin…
GDP2
  • 1,350
  • 9
  • 25
2
votes
1 answer

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 it seems to only act on save. It was working…
Gauthier
  • 509
  • 2
  • 13
2
votes
1 answer

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? Maybe not with whitespace-mode? As a separate…
Cheeso
  • 245
  • 3
  • 8
1
vote
1 answer

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 asdasdasdasd asdasdasdasdasdasd asdasd asdasd asdasdasd …
Emmanuel Goldstein
  • 1,014
  • 8
  • 18
1
vote
1 answer

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?
ideasman42
  • 8,786
  • 1
  • 32
  • 114
1
vote
1 answer

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?
ideasman42
  • 8,786
  • 1
  • 32
  • 114
1
vote
2 answers

Delete all spaces+newlines but the first

Given the following buffer: foo bar nee nope If I place point on the 2nd line and execute (just-one-space -1) the result will be: foo bar nee nope Is there a way to modify the behavior such that the newline after 'bar' will be kept, e.g.…
Tom
  • 45
  • 5
1
vote
1 answer

Space before \t is really inserted?

Launch Emacs with emacs -Q, insert a line contains only a \t (| represents the cursor): \t| M-x whitespace-mode, it should looks like (_ represents visual space): »________$ Insert 2 spaces at the beginning of the line, it should now looks…
littleqz
  • 117
  • 3
1
vote
1 answer

Emacsql string query with space

My sqlite database has columns which consist of TEXT objects containing spaces. I'm new to both emacs and programming, and while I want to use emacsql for reasons, it's crucial that I can select on string objects containing spaces. e.g. (emacsql db…
yarrow
  • 31
  • 3
0
votes
1 answer

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 text text text text text text
Emmanuel Goldstein
  • 1,014
  • 8
  • 18
1
2