Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
25 views

Automatically indent logical lines ONLY in Org-mode

I want this: ** This is a heading This is a logical line. But, because I have visual-line-mode on, lines will wrap at the edge, as is just and godly. But, such elegant formatting as you see here ...
0
votes
0answers
16 views

Disable autoalignment on equals

So I've been doing some editing in a domain-specific configuration language whose syntax tends to look a lot like this: large_scope = { variable = 1 other_variable = 2 small_scope = { ...
1
vote
0answers
41 views

c++ mode indentation

If we have a class like the one below emacs is indenting the : (to the initialization list). To be able to match some other editor, is it possible in emacs to indent the : like below? class Test { ...
0
votes
0answers
13 views

How to preserve correct indentation with a macro in a C++ class declaration in cc-mode

The code base I work with uses macros in class declarations e.g. class DLLMACRO SomeClass { SomeClass(); // ... }; (These are for enabling/disabling Windows dll export macros.) This throws off ...
0
votes
0answers
10 views

orgmode radio tables does not preserve indentation for beamer

I want to use org-mode tables to input matrices in math environments in a beamer presentation. One solution I've come across is to use radio tables. However, as default the radio table gets inserted ...
0
votes
1answer
31 views

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

sh-mode won't care if indent-tabs-mode is on, it will still insert spaces instead of tabs! Can this be fixed?
0
votes
1answer
37 views

Emacs: indentation takes 4 spaces instead of 2

When I write code in Emacs and press Return, the indentation is automatically set to 4 spaces even if I set it yo 2: (setq tab-width 2) ; or any other preferred value (defvaralias 'c-basic-offset ...
3
votes
1answer
33 views

formatting of elisp file is different in emacs and other text editor

I'm having an issue with formatting in that when I'm in emacs, the formatting looks fine: but when the file is viewed with a different text editor, the spaces are different. this only occurs in the ...
0
votes
0answers
14 views

Clang-format style indentation for emacs-lisp code

I am wondering if there is an emacs package similar to clang-format that can enforce consistent code-style in emacs-lisp code. Emacs native indentation will only correct indentation for every line, ...
0
votes
0answers
20 views

Tools ans techniques to enforce a coding style, good practices and static analysis and improve robustness

I'm changing my field a little bit and started working in embedded software development, coming form research in functional programing. I'm required to write, set and enforce a codding style, as well ...
1
vote
1answer
43 views

#ifdef __cplusplus nuisance: How to prevent extra indenting?

If you ever wrote header files that have to be used by both C compiler and C++ compiler, you'd encounter this particular ifdef. This construct causes one to insert extra curly braces in the header ...
0
votes
2answers
29 views

How to configure C-M-q and TAB key to expand pre-existing TAB characters into spaces in C/C++ files

In C and C++ files, I want to configure the mode so that any time I request indentation, that it will always expand all of the embedded TAB characters in indentation (at the start of the line, and no ...
0
votes
1answer
27 views

Disable `indent-relative`

What's the right way to disable Emacs' default indent-relative behaviour and make sure that TAB always indents by a single level (be it a tab or whitespace character)? There doesn't seem to much ...
0
votes
2answers
48 views

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

When I edit JavaScript code which exists in an HTML file, I lose code indentation whenever I press Enter. first line of code: second line of code # Press Enter here Result after pressing Enter: ...
0
votes
1answer
46 views

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

In my .emacs i have put following for cuda highlighting: (setq c-default-style '(("c++" . "linux") (java-mode . "java") (awk-mode . "awk") ...
0
votes
0answers
25 views

Proper way to format elisp when defining multiple fields

I have this code snippet in my init file: '(mode-line-inactive ((t (:weight light :box (:line-width -1 :color "blue") :foreground "red" :background "green"...
0
votes
1answer
37 views

How to reveal tabs in the indentation in a cpp file?

My friend and I collaborate on a C++ project and we agree to use 4 whiltespaces for indentation. I am using Emacs and this is my indentation setting (setq-default c-basic-offset 4) By doing this, I ...
1
vote
0answers
35 views

C++-mode indenting performance depends on length of previous function?

Using c++-mode in emacs23. UPDATE: In response to some early comments, I tested on emacs24 and emacs25, and see exactly the same behavior. I don't have convenient access to emacs26 or emacs27 (25 ...
1
vote
1answer
23 views

Electric indent: Inserting blank lines with no whitespace while keeping cursor indented?

I do a lot of python coding and am trying to determine if electric indent can be customized to help me with the following scenario: Let's say my cursor (point) is at the end of the following excerpt, ...
0
votes
0answers
14 views

How to make brackets be indented on the same line as declatadin

//i want autoindentation be like this int main(void) { //main body if(true) { //if body } return(0); } how can I achive this in cc-mode? I found that there is something like hanging-braces, ...
0
votes
1answer
64 views

Unwanted indentation in org + evil

From an org heading, pressing evil o will open a new line that's indented according to the heading (org level + 1 spaces). Can this behaviour be turned off?
2
votes
1answer
21 views

In M-x Info (C-h i), tables are not correctly aligned

Problem When trying to browse documentation in M-x info ≡ C-h i, the table of contents is not correctly aligned. One would expect * Introduction This is the etc etc etc etc etc . * Details ...
0
votes
0answers
50 views

TAB region indentation (python)

I'm working on a .py document using a fresh apt install of emacs 25.2.2 on Ubuntu 18.04. When typing TAB with several lines selected, the behavior is not what I remember getting previously, and not ...
3
votes
1answer
94 views

Make emacs to use only tabs for JS indentation

I've set my tabs to 4 and haven't changed any JS indent settings. All the indents I found in the "JavaScript group" have values either 0 or 4, yet the following code describe('test Info', () => { ...
0
votes
0answers
14 views

JDEE following line indentation

Is there any way to indent the following lines in e.g. a function to less than the opening brace. Instead of public static void fun(String hello, String world) { ... it would ...
2
votes
1answer
45 views

Indentation of multi-line arrays within braces?

Currently in C mode, contents of a muli-line arrays are aligned with the brace. eg: const unsigned int array[4] = { A, B, ...
0
votes
1answer
190 views

How to indent with the tab character with a visual length of 4 spaces in spacemacs?

I have used Vim for years now, Emacs for a couple of weeks and recently switched to Spacemacs. How do I set indentation settings either globally or the C/C++ mode? (A solution for either one is fine.) ...
0
votes
0answers
24 views

How to enable SHIFT+TAB for multi line code region unindentation?

I have found this code which enables both TAB and SHIFT+TAB for code region indentation and unindentation. The problem is SHIFT+TAB doesn't work on multi line codes and also we have to place the ...
5
votes
2answers
80 views

Org-mode : disable indentation when promoting and demoting trees + subtrees

In org-mode, when you press M-S-right or M-S-left to demote or promote a tree with all it's subtrees, the content text is also indented. So suppose I want to deomote the following structure by two ...
0
votes
0answers
32 views

Spacemacs + Coffee-mode, indents keeps doubling

I'm relatively new to spacemacs. I am editing a coffee-script file, so am using coffee-mode The indents keeps doubling... so 4, 8, 16, 32 .... the further I nest... Example what's wrong: (When I ...
0
votes
0answers
42 views

web-mode indents unclosed tags

The following is valid HTML. <p><a href="page1.html">Page one</a> <p><a href="page2.html">Page two</a> <p><a href="page3.html">Page three</a> ...
1
vote
1answer
24 views

Indentation incorrect in line with `if:` or `unless:` as options, not directives

In some of my ruby files, mostly Rails Model files, I often encounter lines such as: validates :thing_id, presence: { message: '^Choose a Thing' }, on: :create, unless: Proc.new { |obj| ......
4
votes
0answers
48 views

indent cl-loop to respect `if else` statements

I have a hard time writing and reading cl-loops with they way they're indented by default as I can't easily tell what the control flow is: (cl-loop for x below 10 if (cl-oddp x) ...
0
votes
1answer
21 views

get “jump to column” behavior of fundamental mode in a major mode

I noticed that when in fundamental-mode or prog-mode (basically any mode without an indent-line-function) the TAB key will jump between columns. For example if I have foo bar baz fot bat| ...
1
vote
1answer
40 views

javscript “.” indent in web-mode

In web-mode, the indentation after "." var context = cubism.context() .step(1e4) .size(+d33.select("#using-cubism2") .style("...
0
votes
1answer
63 views

Single/simple way to set indentation to 2 for all modes

I'm a bit confused about setting indentation for different modes in Emacs. It seems you have to explicitly set indentation for each mode Some modes use setq-default, some use setq and some use add-...
4
votes
1answer
78 views

Bash script is indented inconsistently

Open the code below with emacs -q, do set-variable sh-basic-offset 2, then indent-region. All lines are indented with 2, while the echo line is indented with 4. Is this a bug in Emacs, or how do I ...
0
votes
1answer
32 views

pressing return in paragraph-indent-text-mode deletes whitespace indenting beginning of paragraph

I'm currently using emacs 25.3 on Mac OSX installed using Homebrew, and without any modifications in my .emacs file or anywhere else. I think I may be fundamentally misunderstanding what paragraph-...
1
vote
0answers
72 views

org-cycle behaves differently for src blocks when evil-mode is enabled

I'm trying to indent my code in org src blocks, but it only works when evil-mode is disabled. I have set this variables for org-mode: (setq org-src-preserve-indentation t org-src-tab-acts-...
1
vote
1answer
128 views

Extra indentation for argument lists beginning on a new line

I'm fine-tuning my C++ style using c-add-style, but I've reached an impasse where I cannot convince Emacs to (extra) indent arguments where the first argument starts on a new line. When I'm forced to ...
0
votes
0answers
32 views

load remote .el file in .dir-locals.el?

Can I use .dir-local.el to load a (remote) file with indentation setting, something like: In .dir-locals.el: ((clojure-mode (eval . (load "~/emacs/indents.el")))) In indents.el: ;; use 2 spaces ...
0
votes
0answers
65 views

How can I change the indent size to 2 spaces in r-mode?

I have tried using (setq r-indent-level 2) but that doesn't seem to work. I would like to set the indent to 2 spaces instead of 4 in R.
0
votes
1answer
48 views

Customized c-offsets-alist override c-file-style in dir-locals

Assuming I customized my default C indentation settings through M-x customize-variable c-offsets-alist: (custom-set-variables '(c-offsets-alist (quote ((statement-case-open . 0) (...
0
votes
2answers
188 views

prevent auto indent temporarily for multi line conditional, loops, etc

When I am writing in c-mode, I prefer to write multi-line control statements in the following way. if( cond1 && cond2 || cond3 ) { /* stuff */ } for( i = 0; i < N; ++i ) { ...
0
votes
1answer
24 views

Which value for topmost-intro-cont, to align variable names in c-mode?

In c-mode, how to align following code so, that the second variable name's starting character (A) is aligned below the first variable name's starting character (V)? static unsigned int V_name_1, ...
0
votes
0answers
31 views

How to indent c++ “special” source lines that don't end with semicolons

I'm working with a system that uses special macros a lot. For instance: class UDSSLib : public UFunctionLibrary { GENERATED_BODY() void foo(); int i; } The problem is the GENERATED_BODY() line....
1
vote
3answers
90 views

Indenting `cl-flet` etc

Is there a way to indent cl-flet, cl-labels etc. using the CL style without resorting to (setq lisp-indent-function #'common-lisp-indent-function)? cl-indent.el claims that: common-lisp-indent-...
0
votes
0answers
16 views

Align closing bracket of multiline array left when used as method argument

When I pass a multiline array as an argument, I'd prefer that the elements were aligned like this safe_join([ "abc", "def", ]) But ruby-mode indents it like this: safe_join([ "abc", ...
0
votes
0answers
24 views

Change Java indentation spacing of && ampersand

I'm having some trouble finding the customization of Java style in Emacs for newline && ampersands. I'm using just electric indent mode. Current style: return c.booleanSomething() &&...
0
votes
2answers
88 views

Is there a way to disable automatic indentation when editing an existing line?

There are cases where my indentation style does not follow what Emacs thinks it should be. (I believe that coding standards should be guidelines, not strict rules, and that deviations should be ...