Use command indent-rigidly, which is bound to C-x TAB by default.
You can specify the number of spaces to indent by using a prefix argument, such as C-5 C-x TAB.
Or you can invoke the command and then use the left/right arrows to interactively adjust the indent level.
Use M-s SPC during Isearch to toggle matching whitespace literally. When matching literally, each SPC char you type is matched individually. (This used to be the default Emacs behavior, BTW.)
To configure this as the default behavior customize option search-whitespace-regexp to nil. (M-x customize-option search-whitespace-regexp.)
See the GNU Emacs manual,...
According to the EmacsWiki, M-x delete-trailing-whitespace will eliminate all trailing whitespace in a buffer. In Spacemacs, it is bound to SPC x d w by default
You can do it automatically for all buffers by adding the following to your init.el:
(add-hook 'before-save-hook 'delete-trailing-whitespace)
For future reference, you can search for Emacs ...
What's the idiomatic (or best) way to trim surrounding whitespace from a string?
The built-in library subr-x.el has included the inline functions string-trim-left, string-trim-right, and string-trim since Emacs 24.4:
(eval-when-compile (require 'subr-x))
(string-trim "\n\r\s\tfoo\n\r\s\t") ; => "foo"
Since Emacs 26.1 these inline functions also accept ...
The variable org-tags-column controls the distance of tags at the end of the heading. To have just one space, the original poster may wish to consider using:
(setq org-tags-column 0)
To apply the changes on an existing org file, use C-u C-c C-q
The doc-string for org-tags-column, which can be seen by typing M-x describe-variable RET org-tags-column RET ...
You can use ClangFormat to achieve this. After installing the clang-format tool, you can use clang-format.el to perform the appropriate actions from emacs. clang-format.el is also available from MELPA. The emacs commands provided are clang-format-buffer and clang-format-region which you can bind as you need. Note that you can customize formatting options by ...
First off, since you didn't mention it: Using the same version of Emacs (24.4.1), the behavior you describe can be reproduced in emacs -Q.
Secondly, what you are doing should work (AFAICT). It seems that turning on whitespace-mode globally (or even in a mode hook) before visiting a file with a custom whitespace-line-column is what's causing the problem. You ...
You might find the hungry-delete package useful. I personally bind C-cdelete to delete whitespace after point, and C-cbackspace to delete whitespace before point like so
(global-set-key (kbd "C-c <backspace>") 'hungry-delete-backward)
(global-set-key (kbd "C-c <deletechar>") 'hungry-delete-forward)
update: as of 12.2018 function definitions ...
The buffer-local indent-tabs-mode variable controls this (in general, for any mode).
(defun my-js-mode-hook ()
"Custom `js-mode' behaviours."
(setq indent-tabs-mode nil))
(add-hook 'js-mode-hook 'my-js-mode-hook)
I just added the following to my init.el:
(defun prevent-whitespace-mode-for-magit ()
(not (derived-mode-p 'magit-mode)))
(add-function :before-while whitespace-enable-predicate 'prevent-whitespace-mode-for-magit)
This basically advises the function whitespace-enable-predicate, which whitespace-mode uses to determine, which buffers should receive global-...
There is the string manipulation library s.el where trimming whitespace and newlines at the beginning and the end of a string is implemented as function s-trim. I cite that function here with its dependencies:
(defun s-trim-left (s)
"Remove whitespace at the beginning of S."
(declare (pure t) (side-effect-free t))
The string-rectangle command ( C-x r t) can be used to insert any arbitrary text (spaces included) in a selected region.
Let's say you have this block of text and you want to insert 5 spaces in front of all lines.
First select a "0 column" region as shown below (the point is on the character 'a' and the mark is in the same column in the ...
Ignoring whitespace-mode, there's always:
(setq-default show-trailing-whitespace t)
M-x customize-face RET trailing-whitespace RET
which might not give you that exact visualisation, but will let you visualise trailing whitespace nevertheless.
I also have a keybinding for this:
(defun toggle-show-trailing-whitespace ()
The documentation in the emacs manual says:
Whitespace mode is a buffer-local minor mode that lets you
“visualize” many kinds of whitespace in the buffer, by either drawing
the whitespace characters with a special face or displaying them as
The relevant docstrings contain more information. So let's say we
want do display spaces as ·...
If you want this to act in any buffer, not just a file-visiting buffer then find-file-hook is not appropriate. (You said "all buffers", but you also spoke of editable/non-editable "files".)
If you want it to work in all buffers then this is one solution:
(defun my-show-trailing-ws ()
"Show trailing whitespace in the current buffer, unless it is read-only....
Try M-x whitespace-mode to toggle display of space, line breaks, etc. You can set whitespace-style to control what gets displayed. (Try M-x customize-variable whitespace-style to see what options are available.)
You might also try: M-x customize-group whitespace, to see all the related options -- whether to turn on whitespace-mode globally, how to display ...
This should do what you want. Define regexps that match what you want, and faces.
Then match the subgroups in the function you add to font-lock-keywords. The subgroups are used to say that you want only the spaces after indenting tabs, and only non-indenting tabs.
(defface my-tab '((t (:background "LemonChiffon"))) "..." :group 'faces)
(defface my-space '...
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.
Quoting from the manual:
The kinds of whitespace visualized are determined by the list variable
whitespace-style. Individual elements in that list can be toggled on
or off in the current buffer by typing M-x whitespace-toggle-options.
You're setting whitespace-style with this code:
(setq whitespace-style (quote (face spaces tabs newline space-mark ...
You should generally start Emacs with emacs -q to make sure it's not your configuration. If that doesn't get rid of it, but emacs -Q does, chances are it's the way your Emacs was packaged or a site file that's used for every user on your system.
Additionally to that you can inspect the faces involved by placing point at the highlighted area and doing M-x ...
The Emacs Manual (section Special Isearch) says this:
By default, incremental search performs lax space matching: each space, or sequence of spaces, matches any sequence of one or more spaces in the text. Hence, "foo bar" matches "foo bar", "foo bar", "foo bar", and so on (but not "foobar"). More precisely, Emacs matches each sequence of space ...
I use this quite often:
(defun join-line* ()
"Join this line with the next line deleting extra white space."
(global-set-key (kbd "M-j") #'join-line*) ;; just key binding I use…
(defun blank-line-p (&optional pos)
"Returns `t' if line (optionally, line at POS) is empty or
composed only of whitespace."
(goto-char (or pos (point)))
(progn (skip-syntax-forward " ") (point)))))
You can use skip-syntax-forward to skip non-whitespace. Docstring:
(skip-syntax-forward SYNTAX &optional LIM)
Move point forward across chars in specified syntax classes.
SYNTAX is a string of syntax code characters.
Stop before a char whose syntax is not in SYNTAX, or at position LIM.
If SYNTAX starts with ^, skip characters whose syntax ...
This is a known problem as made evident in a comment in whitespace.el:
(space-mark ?\ [?\u00B7] [?.]) ; space - centered dot
(space-mark ?\xA0 [?\u00A4] [?_]) ; hard space - currency
;; NEWLINE is displayed using the face `whitespace-newline'
(newline-mark ?\n [?$ ?...
There is a set of conventions for minor modes documented in the docstring of define-minor-mode:
The defined mode command takes one optional (prefix) argument.
Interactively with no prefix argument, it toggles the mode.
A prefix argument enables the mode if the argument is positive,
and disables it otherwise.
When called from Lisp, the mode ...