Is there a way to prevent Emacs from converting tabs to spaces by default upon buffer save?
Related
In vscode, when I open a file containing unicode characters,
I notice that tabs do not always advance to the next tab stop.
For example, the following might be part of an ASCII-flavor table
a<tab>b<tab>c<tab>d<tab>e
α<tab>β<tab>γ<tab>δ<tab>ε
𝔸<tab>𝔹<tab>ℂ<tab>𝔻<tab>𝔼
While sublime text renders it correctly(IMO)
vscdoe has a different idea
As I understand it, vscode renders a tab by
replacing it with a proper number of space characters.
So if there are characters showing using proportional fonts,
no integer number of spaces will make it to the proper stop.
(See this related issue.)
So my question is, how can I fix this?
Is it possible to tell vscode that
"Fine, if you were to assume that those unicode characters
are 2 spaces wide when tabbing,
would you please render them as 2 spaces wide?"
I have a file in Visual Studio Code in which I use only tabs for indentation. When I copy the contents of that file somewhere else and edit them, then when I paste them back all tabs are gone and spaces have taken their places.
How can I prevent the use of spaces for indentation and automatically spaces will be converted to tabs?
Also I have changed the preferences:
"editor.insertSpaces": false,
"editor.detectIndentation": false,
Unfortunately you can't (yet). I think it would be nice to get spaces/tabs converted upon file opening - like some editors do. You can quickly convert spaces by tabs by selecting the number of indentation spaces, pressing cmd+F2 in mac or ctrl-F2 in linux/windows (to find and select all occurrences of that amount of spaces), and then pressing tab key (only once). You can also give Untabfy (or Whitespacer) a try.
This answer nicely provides a way to display characters rather than tabs (in the example it suggests ">", but I confirmed it works for ".").
It uses setting the active window display table to do it.
Now my goal is to display 4 spaces as 4 dots. Using the font-face and a regular expression, I am confident that I can display it nicely. I am aware that I could have Emacs automatically use tab characters rather than whitespaces, but I always prefer to have whitespace characters in my files.
I've also looked at whitespace mode, but I tweaked many parameters and in the end I never get the simple dots (with a face that makes it a little less "jump" out).
So: how can I, rather than display tab characters as dots, display 4 spaces elegantly as dots in Emacs?
OK, here's how to mark 4 or more spaces at beginning of line
(setq whitespace-space-regexp "^\\( \\{4,\\}\\)")
And here's how to get rid of the centered dot character for space:
(setq whitespace-display-mappings
'((space-mark ?\ [?\ ] [?.])
(space-mark ?\xA0 [?\ ] [?_])
(newline-mark ?\n [?$ ?\n])
(tab-mark ?\t [?\u00BB ?\t] [?\\ ?\t])))
The changes take effect not immediately but when you revert-buffer or
close it and open again with customizations above already set.
I write mostly my documentation in HTML using emacs as my main editor. Emacs let you interactively spell-check the current buffer with the command ispell-buffer. (I think the underlying program used for doing the spell-check is named aspell.)
When emacs is in HTML-mode, text is stripped for all HTML markup before the remaining text is being spell-checked.
However, soft-hyphen entities ( or ) are not stripped, so a word that is written as specifies in the HTML text is spell-checked as two separate words (speci and fies) which is not what is wanted.
Is there a way to make emacs ispell/aspell ignore shoft hyphens in HTML?
Or can anyone suggest an elisp function that will strip soft hyphens out of the HTML text before it being handed over to aspell for spell-checking?
I'm editing a text-document styled on its own way of which Emacs doesn't recognize the markup, and opens it in fundamental-mode. Tab indentation is the most problematic behaviour.
Can I fix tab width with a runtime command, only for the current session?
Particularly I'd avoid any permanent in-file configuration.
You can use M-x set-variable to set variables at runtime and only for that buffer and session, ideally you can set the offset variable (for instance in c-common-mode it's c-basic-offset) and you can change this value to the desired tab width (although I recommend you use spaces instead of tabs for consistency as tab characters \t are usually 8 spaces wide.