Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 454

Indenting is used to organize code by indicating blocks, closures, conditionals, and other constructs. It makes code easier to read, and in some languages is used to handle control flow.

1 vote
Accepted

What is the difference between a tab stop and a tab width?

C-hig (emacs)Indentation The simplest way to perform indentation is the <TAB> key. In most major modes, this runs the command ‘indent-for-tab-command’. … If point was initially within the current line’s indentation, it is repositioned to the first non-whitespace character on the line. …
phils's user avatar
  • 53k
1 vote

Emacs 28.1: Bash Shell Script Indenting does not recognize if [....];then

I can reproduce this and it seems like a bug (please do report it), but you can work around it by putting a space after the semicolon (which I think almost everyone does, which would explain why this …
phils's user avatar
  • 53k
1 vote

Use spaces for indentation in Protocol-Buffers mode

Assuming you're referring to protobuf-mode in MELPA, there is config documentation in its Commentary. Use either of: M-x find-library RET protobuf-mode RET M-x finder-commentary RET protobuf-mode RET …
phils's user avatar
  • 53k
2 votes

How to NOT Auto Indent when a specific Character is inputted?

C-hk( tells us: ( runs the command c-electric-paren (found in c-mode-map), which is an interactive compiled Lisp function in ‘cc-cmds.el’. It is bound to ), (. I suggest: (with-eval-after-load "cc-m …
phils's user avatar
  • 53k
0 votes

How can I represent a 4 spaces indent width as 2 spaces?

If the indentation is spaces rather than tabs, give redshift-indent a try. … e.g.: With prefix arg 2, indentation will appear 2 times its normal width. …
phils's user avatar
  • 53k
3 votes
Accepted

Why does emacs sh-mode ignore indent-tabs-mode?

That said, I find tabs bad for shell script indentation, as copying and pasting code from a script into a shell running in a terminal can be problematic. …
phils's user avatar
  • 53k
1 vote

How to prevent losing indentation when editing JavaScript code within HTML files in Emacs?

That's due to electric-indent-mode, which is a global minor mode. You could add (electric-indent-mode -1) to your init file to disable it entirely, or you could try using a custom electric-indent-fun …
phils's user avatar
  • 53k
1 vote

cuda .cu files indentation issue. How i can set indentation for cuda .cu files to 4 spaces?

The "gnu" style sets c-basic-offset to 2, so that's where that's coming from. As you have specific needs for a specific filename extension, I'd probably just define a derived mode to use with auto-mo …
phils's user avatar
  • 53k
1 vote
Accepted

get "jump to column" behavior of fundamental mode in a major mode

I noticed that when in ... any mode without an indent-line-function ... the TAB key will jump between columns. I think you've noticed and ignored the answer to your own question. Those modes are …
phils's user avatar
  • 53k
1 vote
Accepted

White space being inserted before a semicolon in asm-mode

In asm-mode, C-hk; reports that ; is bound to asm-comment. The Commentary for asm-mode.el (M-x find-library RET asm-mode RET) says: This minor mode is based on text mode. It defines a private abbre …
phils's user avatar
  • 53k
1 vote
Accepted

Function that deletes redundant leading whitespaces of a region while maintaining indentation

This is a variant of my answer to copy region without leading indentation which acts directly in the original buffer. … (interactive "P\nr") (save-excursion ;; Establish the minimum level of indentation. …
phils's user avatar
  • 53k
5 votes
Accepted

copy region without leading indentation

(with-temp-buffer (setq indent-tabs-mode itm tab-width tw) (set-syntax-table st) (insert-buffer-substring buf beginning end) ;; Establish the minimum level of indentation
phils's user avatar
  • 53k
4 votes
Accepted

inverse of 'indent-tabs-mode'

(setq indent-tabs-mode t)) Provided java-mode only ever indents to multiples of tab-width, this ought to give you tab-only indentation. … If not, you would need to determine how to control the level of indentation in java-mode so that you can set that (and/or tab-width -- another buffer-local value) to coincide, so that only tabs will be …
phils's user avatar
  • 53k
1 vote

Indent with 4 spaces, but display 2

Don't use this version if you use tabs for indentation (although unless you're mixing spaces and tabs, you didn't have a problem to begin with, as for the tabs-only approach you can simply adjust tab-width … I decided to pop it on the Wiki as-is on account of seeing another question View code with different indentation than saved to disk -- before I realised that the other question wasn't actually a duplicate …
phils's user avatar
  • 53k
1 vote

Change the behaviour of RET (with electric indent) to only indent the new line, not the prev...

These functions take care of indentation, and also comment continuation when you're inside one. (defun my-coding-config () ;; ... …
phils's user avatar
  • 53k

15 30 50 per page