By default I want all indentation (when I hit the tab key) to be 2 spaces.
This can be achieved for many modes with settings such as
(setq-default indent-tabs-mode nil
Every time I open a file I see Can’t guess python-indent-offset, using defaults: 4
The default indentation offset for ...
The built-in CSS mode should support this just fine by giving indent-tabs-mode a non-nil value.
Note that spaces will still be used for padding if the number of indentation spaces isn't a multiple of tab-width. The default values of tab-width and css-indent-offset are 8 and 4 respectively, so you'll need two levels of indentation before a tab is inserted.
The first line when enabling python-mode is (set (make-local-variable 'tab-width) 8). Because tab-width is a buffer-local variable, a new value would need to be set subsequent to the code above. The most common way this is done is with a major-mode hook, in this case the python-mode-hook.
There is also a variable called python-indent-offset, which is used ...
You can set up your own protocols in org-link-parameters with org-link-set-parameters.
If you run
(org-link-set-parameters "chrome" :follow (lambda (path) (browse-url-chrome (concat "http:" path))))
(org-link-set-parameters "chromes" :follow (lambda (path) (browse-url-chrome (concat "https:" path))))
(org-link-set-parameters "chromium" :follow (lambda (...
Like most things in emacs, the tabs policy is configurable. It sounds to me that you'd like to follow the most common apporach and use the tab key as an indentation tool and not have tab characters in your files at all.
First, you should set (setq-default indent-tabs-mode nil) early on in your emacs config. To convert existing files, emacs comes with ...
Here's some proof-of-concept code that displays tabs with a variable width. It kicks in if you turn on Font lock mode in a buffer where one of the variables variable-tabs-tab-stop-initial-list or variable-tabs-tab-stop-repeat-list is set to a non-nil value (typically through a file-local variable). These variable contain a list of column widths; first the ...
One method of setting variables on a per-file basis is to write a local variable specification in the first line of the file. The details for doing this are in §188.8.131.52 ‘Specifying File Variables’ of the Emacs manual.
A local variable specification takes the following form:
-*- mode: MODENAME; VAR: VALUE; ... -*-
You can repeat VAR: VALUE; for as many ...
You should use regular expression replacement.
I'll describe how I would do the replacement with swiper, the built-in isearch-forward-regexp would work in a similar way but with more keys.
Enter .* C-q TAB .*. There is a single space on each side of the tab char in the middle.
Under the hood, swiper translates the input string ".*...
This is not necessarily a direct answers to what you should put in your .emacs file but rather a more generic way to quickly figure out the parameters for the style you've chosen.
cc-mode provide several functions to directly guess the right indentation parameters. They are aptly prefixed with c-guess-.
For this case in particular you could use the ...
I feel kind of ridiculous for not having seen this before, but I found the answer on the EmacsWiki: No Tabs page under the "Smart inference of indentation style" section. Putting that code in my init.el file (and those last 2 lines in my python-mode-hook) got Emacs to know whether tabs or spaces were being used.
The normal convention is that TAB characters align to the next multiple-of-8 column. Notice: I wrote 8, not 4.
So if your other text editor aligns to a multiple-of-4 column (like you seem to imply), it could be argued that it's a bug in that other editor (tho it's more likely that you have customized that editor (explicitly/knowingly or not) to use a "tab-...
You can try quarter-plane-mode (available from GNU ELPA), but beware. Emacs's underlying engine is basically unable to do what you want; it can only place cursor where there is some text), so the package has to do funny things (e.g. it will add spaces as/when needed, IIRC) which will occasionally have side-effects that might surprise you.
To make tabs and spaces visible, you can enable whitespace-mode with M-x whitespace-mode RET or M-x global-whitespace-mode RET. Have a look at variable whitespace-style (e.g. M-x customize RET whitespace-style RET).
As you found, indent-rigidly (which you're running with C-x TAB) indents with both tabs and spaces. It will use tabs as much as possible and ...
I thought [Space] might have meant it was a minor mode
The mode line lighter Conf[Space] corresponds to conf-space-mode, which is a major mode derived from conf-mode for editing space-separated configuration files (i.e. ones where key-value pairs are separated by arbitrary-length whitespace), such as ~/.ssh/config under Unices. conf-space-mode has nothing ...
Well, just as a challenge, here's some Emacs Lisp code to do something slightly more general than just swapping two selected columns:
(defun my/determine-column (col line)
(cl-loop for word in line
for i from 0
summing (length word) into total
if (> total col) do
finally (cl-return (1-...
My course of action would be:
Copy the data into Org file (or buffer, where I then call M-xorg-mode).
C-u C-u C-c | to convert it to an Org table.
Manipulate the table columns as I need.
Unfortunately, you can't.
Consider this piece of code.
x = 0
x += 1
x += 2
You can't programmatically decide if that block should become this
x = 0
x += 1
x += 2
x = 0
x += 1
x += 2
It's almost impossible to fix inconsistent spaces with a program.
However you can write a simple function to change ...
This depends on how you have configured Emacs, which is not clear to me from the question.
Your buffer text might contain spaces or tab characters, depending on your settings. Copying and pasting the text won't change the actual characters. If you copy text containing a tab control character it will be pasted as a tab (\t) and the way it is displayed will ...
The function below checks if the point is in a string using syntax-ppss and inserts a TAB if it is, otherwise calls indent-for-tab-command, which is what TAB is bound to in go-mode.
(defun my-indent-or-insert-tab (arg)
"Insert TAB if point is in a string, otherwise call
(if (nth 3 (syntax-ppss (point)))
(Nearly) all programming modes inherit from prog-mode, so you can set the variable in prog-mode-hook:
(defun my-prog-mode-hook ()
(setq tab-width 2))
(add-hook 'prog-mode-hook #'my-prog-mode-hook)
(Note that you could use a lambda instead, but this way you'll have an easier time removing the hook if you ever want to do so.)
Well, the answer to "is it possible to make Emacs do " is almost always "yes". If you really just want to insert five spaces with a TAB, you could do it by:
(defun my-tab-with-spaces ()
"Insert five spaces for a tab the way I like it."
(insert " "))
What TAB does now is indent-for-tab-command. What you want is tab-to-tab-stop.
The latter is available at M-i, so one option is to learn to use that.
To always bind TAB to run that command in Text mode, you can put
(define-key text-mode-map "\t" 'tab-to-tab-stop)))
in your init file.
There's a space in the buffer, but in certain circumstances, when Emacs needs to print a sequence of spaces, it chooses to print a tab instead because that requires writing fewer characters to the terminal. This is what's happening when you insert the characters one by one. It doesn't happen when Emacs is printing the line all in one go, for example ...
The Ruby editing mode defines ruby-indent-tabs-mode and sets indent-tabs-mode to that value when the mode is invoked. The default for this is nil. To fix your problem, set this variable instead.
This seems like a bug to me. There's no reason Ruby needs its own special setting for this.
Note also that c-basic-offset doesn't affect Ruby. Ruby has ruby-...
From the description of tabify:
A group of spaces is partially replaced by tabs
when this can be done without changing the column they end at.
So it seems like it's behaviour depends on tab-width variable.
Maybe something like this? I haven't tested it with tabs though...
(defun char-below ()
(setq temporary-goal-column nil)
If you want it to return nil when there's no char below, because the row below is shorter than the current position, this is a modification:
(defun char-below ()
(let ((col (current-column)))
(if (not (zerop (forward-line 1)))
(and (not (eolp)) (char-after))))))
But you don't say what you mean by "it breaks down in case the line below has tabs" or "accounting for the presence of tabs".
If you want to consider that ...
First of all you should set the default value of indent-tabs-mode to nil.
Either toggle it off with customize or put the following lisp code into your init file.
(setq-default indent-tabs-mode nil)
You can check for tabs in a file with M-x white-space-mode in its buffer. Tabs are indicated with » when that mode is active.
If you want to prominently ...