Skip to main content

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
1 vote
0 answers
15 views

Add preprocessor like prefix for C/C++ indentation

I want to extend the existing indentation capabilities for macro constructs which behave like preprocessor directives. Consider the following code example: void fkt() { const int a = 0; MY_MACRO(...
theldoria's user avatar
  • 1,845
1 vote
1 answer
45 views

How to strip/normalise indent on paste?

It's often the case that I want to move a code block from one place to another that has a different level of indent. Here's an example Haskell snippet: someFunc = withSystemTempDirectory "test&...
Atemu's user avatar
  • 322
2 votes
1 answer
35 views

getting macro calls to indent correctly (like defun instead of functions) in common lisp code?

I'm editing a Common lisp (not elisp) source file; bottom right says (Lisp adoc [COMMON-LISP-USER sbcl]). I'm using slime, so I'm pretty sure that's what the adoc means. I have the following in a ...
xdavidliu's user avatar
  • 213
0 votes
0 answers
13 views

Correct tree-sitter based indentation for d-ts-mode.el

I've put together a d-ts-mode for the D programming language at https://gitlab.com/per.nordlow/elisp/-/blob/main/d-ts-mode.el. The indentation doesn't work for all cases. Does anyone have advice on ...
Nordlöw's user avatar
  • 507
1 vote
1 answer
45 views

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

Greetings lately I've been trying to learn Emacs and configure it as an IDE, so I started learning the basics, until I got to the segment of configuring indentations. I do understand that the term Tab ...
KhodeNima's user avatar
  • 113
1 vote
2 answers
42 views

web-mode doesn't give correct indentation

I have the following lines activated: (setq indent-tabs-mode nil) (setq tab-width 1) (setq web-mode-markup-indent-offset 1) (setq web-mode-css-indent-offset 1) (setq web-mode-code-indent-offset 1) ...
Alexander Mirnyy's user avatar
0 votes
1 answer
31 views

Unexpected (lack of) indentation in C++ end-of-line comments

When using C++ mode I've noticed that the tab key indents the current line. However, if I'm at the end of the line, I would like to be able to use tab to add aligned whitespace so that I can add // ...
finitud's user avatar
  • 101
0 votes
1 answer
20 views

`tab-stop-list` being ignored

Tying to write a new mode, I am stuck at: (define-derived-mode NEWS-mode text-mode "NEWS" "Major mode for NEWS file." (setq tab-stop-list '(2 6 59 65)) (setq indent-tabs-...
emacs drives me nuts's user avatar
0 votes
1 answer
38 views

How to unindent after Org list

GNU Emacs v29.2 Doom core v3.0.0-pre Doom modules v23.12.0-pre So I want to RET/return after some bullet point lists and no longer be indented, but this is my current issue and I don't know ...
sgript's user avatar
  • 103
0 votes
0 answers
43 views

Indentation in org num mode

When working with both org indent mode and org num mode turned on, I observe that text lines are aligned with the outline numbering, like so which looks cluttered to me. Instead I'd prefer an ...
user42469's user avatar
1 vote
1 answer
49 views

How best to cope with Dragon speech recognition occasionally adding blank spaces at the beginning of lines?

BRIEF: When speech recognition software occasionally inserts extra blank spaces at the beginning of lines that are being dictated into emacs fundamental or textmode, how can the bad stuff below be ...
Krazy Glew's user avatar
0 votes
1 answer
65 views

In Org-mode, how to disable indentation of first line of a paragraph?

When converting from Org-mode to PDF, the first line of a paragraph is automatically indented: aaaaaa bbbbb ccccc ddddd eee ee fffff ggggg This is fine. However, I would like to disable it when I ...
Pietro's user avatar
  • 121
0 votes
0 answers
16 views

How to auto insert new line when hit return key between {}

When write functino in c.c like this: int main(){} After I hit return key between {}, it goes like this: int main(){ } How could I get it to work like this: int main() { >position of cursor ...
C-Entropy's user avatar
  • 143
0 votes
1 answer
66 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
  • 293
0 votes
1 answer
55 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
1 vote
1 answer
119 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
80 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
31 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
176 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
23 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
28 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
79 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.
fuch your face's user avatar
1 vote
1 answer
46 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
12 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
25 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
48 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
17 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
27 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 ...
whiteman808's user avatar
0 votes
0 answers
33 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
143 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
3 votes
2 answers
2k 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
  • 243
1 vote
1 answer
199 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
59 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
  • 756
0 votes
0 answers
78 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
  • 796
0 votes
1 answer
75 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
127 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,231
0 votes
0 answers
220 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 Gaza's user avatar
0 votes
1 answer
76 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
  • 293
0 votes
1 answer
37 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
  • 379
0 votes
1 answer
40 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
27 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
81 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
106 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,370
1 vote
1 answer
71 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
  • 563
0 votes
1 answer
84 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
  • 153
2 votes
1 answer
605 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
93 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
78 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
555 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,370
1 vote
1 answer
114 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
  • 56

1
2 3 4 5
11