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
0answers
37 views

Whitespace mode only works in fundamental mode but not others (like org, Clojure, etc)

My problem is - the whitespace mode is only showing dots for whitespaces in fundamental mode, however in other modes, like clojure, when whitespace mode is active - nothing happens. I expect the ...
1
vote
1answer
53 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, ...
0
votes
0answers
20 views

How to insert a new space before cursor?

I have links in Org mode that are at the beginning of the line and I struggle to add space before them in the insert mode. It would be great if there was a way to insert a space before the current ...
0
votes
1answer
30 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&...
13
votes
7answers
3k 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
0answers
47 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$, ...
1
vote
1answer
51 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? ...
1
vote
1answer
60 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 ...
6
votes
2answers
1k 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" ...
0
votes
1answer
24 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:
7
votes
2answers
114 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-...
2
votes
1answer
106 views

Highlight missing double-space between sentences?

For a while, I've been using sentence-end-double-space: nil. Now I want to get back into the habit of using two spaces to separate sentences. It is the convention for GNU documentation, and it ...
0
votes
0answers
12 views

Stop indentation from altering pre-formatted text

.preformatted { white-space: pre-wrap; } <div class="preformatted"> THIS TEXT IS PREFORMATTED <= no spaces there, before pasting this text in this code ; It should render ...
1
vote
2answers
73 views

Avoiding typographic “rivers” with Emacs

When reading manuals in *info* mode, I found rivers somewhat distracting. For example, the left image is what I see on the screen, whereas the right one have some rivers annotated out. (see also Tex....
7
votes
3answers
1k 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 ...
1
vote
0answers
41 views

How do I end an org capture template with whitespace?

I want to make an org capture template that ends in whitespace. Specifically, I want to make TODOs that are scheduled. From emacs -Q, I'm starting with this template: (cl-pushnew '("T" "TODO ...
2
votes
2answers
56 views

Convert tabs to spaces when copying text to external applications

I use tabs in C/C++ but want to convert those tabs to spaces when copying code that I'm going to paste into an external program. However, I want the original code to retain tabs. Additionally (if ...
0
votes
2answers
269 views

Confusion about space and tab characters in Emacs

I am confused by space (SPC) and TAB characters in Emacs. I am often using the default fundamental mode. When I select a region and indent the lines in the region by C-u 9 C-x TAB, I intend to ...
0
votes
2answers
105 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> &...
1
vote
4answers
450 views

How remove whitespaces in the beginning of lines?

Emacs 26.1 I has the next text: I need to remove all whitespaces in the beginning of the lines. Every line has different count of whitespaces. The result must be like this:
1
vote
3answers
339 views

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)
3
votes
1answer
55 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 ...
1
vote
1answer
368 views

How to remove empty lines of a selected region of code in Emacs?

Is there a way to remove blank lines from a region of code I select? I am asking because I copy/pasted code and it seems to have several blank lines I want to get rid off.
0
votes
1answer
214 views

How can I ask emacs to show me (visually) invisible characters like CR LF?

The title says it all: I want emacs to show (all, or only some, like CR LF) invisible characters in my buffer? (If it matters: I am using the latest emacs (25) on the latest debian testing) (I am ...
1
vote
2answers
148 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
1answer
70 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 ...
0
votes
1answer
87 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-...
1
vote
1answer
128 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 ...
2
votes
1answer
410 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 ...
2
votes
1answer
248 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 '...
20
votes
3answers
2k 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.
0
votes
2answers
161 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
2answers
311 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 ...
3
votes
1answer
102 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
168 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 ....
2
votes
4answers
668 views

How can I stop emacs from highlighting whitespace?

After a recent update, my Perl files are rendered like this: Note that trailing spaces are shown in red and empty lines in yellow. This is happening despite my having the following in my ~/.emacs: (...
0
votes
1answer
25 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 ...
5
votes
1answer
268 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 ...
5
votes
1answer
926 views

Too much whitespace on setting org-mode tags

If I create the following in an org-mode buffer: * one ** two ** three then move point to the line containing "two" and do C-c C-c spam <RET>, I get this: * one ** two ...
0
votes
2answers
95 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/...
0
votes
1answer
71 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.
3
votes
1answer
258 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' ...
2
votes
0answers
184 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
94 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
66 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? ...
1
vote
1answer
147 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
2k 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 ...
1
vote
1answer
40 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?
3
votes
1answer
2k 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.
3
votes
2answers
546 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 ...