Questions tagged [indentation]

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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
16 views

Evil mode "o" auto indent in text mode - how to turn it off?

When I press o in evil mode (which moves the cursor to the line under, and goes into insert mode), the cursor is indented by two spaces. When I press o, the cursor goes here This happens in text ...
Vinn's user avatar
  • 283
0 votes
1 answer
28 views

c-mode inconsistent indentation (sometimes tabs, sometimes spaces)

I have the following line in my .emacs file: (setq-default indent-tabs-mode nil) but sometimes my indents still come through as tabs rather than spaces in c-mode. It is inconsistent; roughly 70% of my ...
tedtanner's user avatar
0 votes
1 answer
53 views

C offset is 2 with treesit

I recently started using treesit and I'm noticing with C files, my auto-indent is 2 spaces. How can I fix this to make it 4 spaces again? I've tried c-basic-offset.
user129393192's user avatar
0 votes
0 answers
44 views

how to turn off python formatting in emacs

I have a python program that I edit in emacs. However, sometimes when I save it, it gets re-indented, and in doing so, messes up the indentation of sections, where I have some code and then some ...
Christopher Clark's user avatar
0 votes
0 answers
30 views

How do I trim spaces and indentations after traversing a DOM tree?

The following traverse the dom tree and provide an iterative custom formatting. However during the formatting, there are empty spaces and indentations which I needed to trim. ;;; This is where the ...
alexander's user avatar
  • 133
0 votes
1 answer
42 views

Indentation not being followed on TypeScript/TSX

I have problem with the indentation in JSX/TSX files, I'm not sure how to describe it but the thing is that it does not follow the indentation on the file, please take a look the gif below: After ...
Hugo's user avatar
  • 131
1 vote
1 answer
19 views

how to indent strictly in multiples of tabstop (e.g. 4)

Demonstration of the problem: # starting point: function hello_world { _somecommand_ parameter ' | <--- point/cursor is here on step one ' } # the next step (I take issue with): ...
Paxsali's user avatar
  • 181
0 votes
0 answers
24 views

How can I make `fill-paragraph` on selected text respect indentation in AUCTeX?

Using fill-paragraph in AUCTeX normally respects the given indentation. However, if I use fill-paragraph on a selection, only the first line will be indented, the other lines won't. Is there a way to ...
red_trumpet's user avatar
0 votes
2 answers
42 views

How to indent-region with TAB key?

I want to detect if selection made was activated and bind appropriate code for indent-region or ifselection mode was not activate - other code.
Vitalij Chepelev's user avatar
1 vote
1 answer
33 views

Unexpected auto indentation by 8 spaces with AucTeX

It's currently hitting the standard list-like environments and comments but I can't quite figure when exactly it happens, as it looks non-deterministic: sometimes in a big document I actually get a ...
Artem Pelenitsyn's user avatar
0 votes
0 answers
10 views

List Adaptive Fill Keeps Growing for Lists in Olivetti Mode

I'm having trouble with my org lists. They seem to have an ever increasing amount of adaptive-fill as I nest them deeper and deeper. A picture of the problem is below. These are all single lines in ...
FTWynn's user avatar
  • 121
0 votes
0 answers
22 views

perl-mode brace indentation

How can I get perl-mode to indent: func({ foo => 'bar', }); as func({ foo => 'bar', }); without switching to cperl-mode?
marcantonio's user avatar
0 votes
1 answer
37 views

add a new line with the same indentation level as the current line

when python code block gets larger, it's hard to find the right indentation level def foo(): for a in l: # l1 # l1-1 for b in k: # l2 print(a) # (2) print(b) ...
eugene's user avatar
  • 489
0 votes
0 answers
14 views

python, open parenthesis at beginning of line inserts a space

Python code snippet (imin_f, jmin_f), (imax_f, jmax_f) = island_f non_overlap =set() n of non_overlab is behind ( , I can't tell which mode is doing it.. c-h k ( gives. ( runs the command ...
eugene's user avatar
  • 489
0 votes
0 answers
25 views

How can i remove a single space or tab in the hungry mode?

I use package hungry-delete for deleting whole indentation but I don't know how can I force removing a single space or tab in that mode. Is there any way to do it or do I need to temporarily disable ...
lester's user avatar
  • 101
0 votes
0 answers
30 views

.emacs c-mode/indent settings being ignored

I've been using Emacs forever now but more recently all of my new Linux setups start out with broken c-mode settings that I can't figure out how to fix. Changes in .emacs seem to have no effect, as if ...
davorin's user avatar
0 votes
0 answers
68 views

indentation and syntax highlighting stops working randomly

Every now and when emacs indentation and syntax highlighting stops working. This seems to affect all modes that I'm using (primarily org-mode,ess-mode and emacs-lisp-mode), and manifests itself in ...
swhalemwo's user avatar
2 votes
2 answers
1k views

C/C++ with tree sitter: how to change indent?

I use Emacs with tree sitter for c++ code (c++-ts-mode). With usual c++-mode I've used this fix for me: (c-set-offset 'inline-open '0) but I don't understand how to do it in new c++-ts-mode. In ...
Sergey's user avatar
  • 223
1 vote
1 answer
117 views

How do I turn off electric-indent mode within 'Fundamental' mode?

Currently, in my .emacs.d/init.el, I have: (setq-default indent-tabs-mode nil) (setq-default tab-width 4) (setq indent-line-function 'insert-tab) (push (cons "\\*shell\\*" display-buffer--...
user129393192's user avatar
0 votes
0 answers
46 views

SMIE: defining a build.ninja grammar

I'm trying to write a mode in SMIE, to figure out how it works and to create some documentation. build.ninja (a build system used by Meson and others) is a perfect candidate due to its very simple ...
Hi-Angel's user avatar
  • 554
0 votes
0 answers
63 views

How to configure Emacs to support indented C preprocessor statements?

In some cases I deal with code that has heavily indented C preprocessor statements and want to setup Emacs to work with it without changing that indentation and follow the same indentation when having ...
PRouleau's user avatar
  • 786
0 votes
1 answer
55 views

indent-buffer At top level

Not really sure why this has stopped working When I run the command indent-buffer ..it just says At top level Same if I mark the whole buffer and run indent-region. Any way to debug this?;)
Jason Hunter's user avatar
2 votes
2 answers
89 views

Python-mode Multi-line Conditional Indentation

Given the following somewhat silly Python code with a multi-line condition: if ("VALUE" in my_uncessarily_long_dictionary and some_other_long_condition_case): do_something() else: ...
Xaldew's user avatar
  • 1,201
0 votes
0 answers
132 views

How to always use tabs when pressing the tab key?

I use an indentation sensitive language (imba) and I need to always use tabs. I'm using doom emacs and I'm also writing a wip major mode for Imba. But I press tab and it adds indentation using tabs (a ...
Abdellah Stands with Palestine's user avatar
0 votes
1 answer
64 views

How to fix indentation of items below header 3 in org mode?

In org mode, when I do a header 1 or 2, the bullets beneath it snaps to align under the header. But bullets do not indent under for header 3. How do I edit this?
Vinn's user avatar
  • 283
0 votes
1 answer
31 views

Org mode recursive section indentation

I would like to add a "super-heading" with recursive section indentation. By that I mean that I want to transform the content: * Fruits ** Durian ** Jackfruit ** Lychee to become * Produce *...
Sam7919's user avatar
  • 339
0 votes
0 answers
61 views

How to indent curly braces {} in php-mode?

I'm using Doom Emacs with emacs version 28.2. I want to use emacs to write all of my php code using php-mode and all the utilities it brings but the indentation is not what I want. When I type ENTER ...
Pablo Olivares's user avatar
0 votes
0 answers
25 views

How to set brace style for empty function in Doom emacs?

When defining an empty function Doom emacs makes it such that the function automatically looks like this: // after inserting braces void my_func() {} // after pressing enter void my_func() { } /...
Krys's user avatar
  • 95
0 votes
0 answers
14 views

how to get correct indentation in haskell-mode in spacemacs

When in haskell mode indentation is not working quite how I expect it to. When pressing enter in an "else" statement the cursor goes to the beginning of the line instead of the correct one ...
dewijones92's user avatar
0 votes
1 answer
34 views

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

Since upgrade to Emacs 28.1, I have noted an annoy change in shell-script mode auto-formatting. I would like to recover the old behavior Before, if I entered if [ "$x" = "" ];then ...
SzS's user avatar
  • 1
0 votes
0 answers
16 views

Get auto-indentation with newline-and-indent in Scheme REPL

My Scheme REPL is not auto-indenting; I eventually tried just <M-x> newline-and-indent from within a define block in the REPL, and there's no indentation. It works fine in SLIME and .lisp files. ...
zeroclaim's user avatar
0 votes
0 answers
25 views

Indenting inside a sexp "as is the containiing sexp were not there"

I need to customize lisp-indent-function for a particular type of functions in such a way that it would indent lines "as if the function call were not there"; for instance say that I want to ...
Wilder's user avatar
  • 95
0 votes
0 answers
76 views

How to instruct AUCTeX to ignore a specific character when indenting?

I'm writing a document with AUCTeX using the songs package. It all works well, but it requires to input chords like in the sequence \[La]. The problem is, AUCTeX ignores the first bracket (since it is ...
Alessandro Bertulli's user avatar
0 votes
1 answer
82 views

How can I prevent adding a TAB if inner block is already aligned, in `pine-script-mode`?

I am using pine-script-mode with a 4 space TAB. Here is an inner block of an if statement that is already aligned. How can I prevent adding a TAB char (or 4 space chars) when I press TAB? pine file: ...
alper's user avatar
  • 1,300
1 vote
1 answer
63 views

delete backwards until indentation

In my config I have (bind-keys* ("C-<backspace>" . (lambda () (interactive) (kill-line 0)))) which deletes the entire line backwards until column position 0. I would like to only ...
CD86's user avatar
  • 543
0 votes
1 answer
53 views

cant indent with tabs

In my ~/.emacs I have among other things, the following, at the end: (define-key c++-mode-map (kbd "<C-tab>") 'company-irony) (define-key c++-mode-map (kbd "<tab>") '...
dgan's user avatar
  • 143
2 votes
1 answer
402 views

Inconsistent indentation in org-mode

I am an Emacs (and Stack Exchange) newbie, but I think I did my reading. I don't know why Emacs shows an inconsistent indentation in documents longer than one screen. My relevant settings are: (setq ...
Andor Márton Horváth's user avatar
0 votes
1 answer
75 views

Babel C++ blocks have incorrect indentation

When using a C++ source block in org-mode, the indentation doesn't match that of the C++ major mode. Viewing the source block in the org file: Viewing the same code in a C++ mode buffer or using org-...
dag-h's user avatar
  • 1
0 votes
2 answers
72 views

How to remove margin space from multiple paragraphs simultaneously in orgmode

Sometimes when copypasting from the web, orgmode retains the margin in the text. Is there a command in Emacs to remove it? I know of cycle-spacing, but this is slow as it works line by line. Is there ...
Adelita's user avatar
  • 155
1 vote
1 answer
434 views

How to make tab-width 4 space in pine-script-mode?

I am using pine-script-mode for TradingView Pine script. When I follow https://emacs.stackexchange.com/a/17565/18414 I have applied: (defun my-custom-settings-fn () (setq indent-tabs-mode nil) (...
alper's user avatar
  • 1,300
0 votes
1 answer
89 views

How to set up K&R everywhere (1TBS) brace style in cc-mode?

I'd like Emacs to follow this indentation style: struct Foo { void bar() { for (int i=0; i<10; i++) { if (condition) { // code // code ...
sajmon's user avatar
  • 36
1 vote
1 answer
222 views

Use spaces for indentation in Protocol-Buffers mode

Protocol-Buffers mode binds c-indent-line-or-region to the TAB key. Since one of my projects uses 4 spaces for .proto file indentation, I've tried customizing indent-tabs-mode to nil, and tab-width ...
Esteban's user avatar
  • 111
1 vote
1 answer
346 views

indent-region does not respect my c-mode style

This is my C style: (defconst mira-c-style '((c-basic-offset . 4) (indent-tabs-mode . nil) (tab-width . 7) (c-comment-only-line-offset . (0 . 0)) (c-lineup-C-comments . 0) (c-...
Gauthier's user avatar
  • 499
1 vote
2 answers
61 views

format old file to org-indent-mode

I want to convert file created without (org-indent-mode) to (org-indent-mode) format. Mostly it's additional 2,3,4 spaces. I was trying to fix it with string-replace. But maybe somebody have better ...
slk500's user avatar
  • 461
0 votes
1 answer
34 views

Can't set indentation to 4 spaces because hook is not called

I'm trying to set the indentation in C++ files to be 4 spaces. To achieve this I have the following config: (setq-default indent-tabs-mode nil) (setq-default tab-width 4) (defun init-c-cpp () (setq ...
jan's user avatar
  • 103
1 vote
1 answer
50 views

Switch Cases's code block doesn't get indented in JavaScript mode

I'm having trouble with the indentation of the cases's code-blocks in my switch statements it looks like this: switch(var) { case "case1": case's code line 1; case's code line 2; ...
Santiago Lerin's user avatar
0 votes
1 answer
156 views

Comment continuation in block comments

It used to work in c-mode, but I cannot get it back, and now I miss it in rustic, too: If in a block comment, I want Emacs to insert "\n * " after I hit return: /** *<-- [if I hit return ...
Markus's user avatar
  • 101
0 votes
1 answer
77 views

Indentation in HEREDOC

I'm looking for a way to make the indentation in HEREDOCs better. In my case, it's specifically in Ruby, but maybe this is a general question. Basically, I have the following situation: in our tests, ...
flooose's user avatar
  • 511
0 votes
1 answer
201 views

Is it possible to use LSP for font-lock or indentation?

I'm writing C++ and running into problems with font-lock-mode often getting confused by more obscure language features (e.g., operator""_ud). I also find that indentation doesn't work very ...
user3188445's user avatar
0 votes
1 answer
154 views

Why emacs editor changes indent automatically when copy a context into it?

I'm using web-mode package. The source(.tsx file) in Emacs before: import React from "react"; export default { ... args: { name: "", // Here }, decorators, }; The ...
Alpin Cleopatra's user avatar

1
2 3 4 5
11