Questions tagged [indentation]

Prefixing lines with whitespace to aid in readability.

Filter by
Sorted by
Tagged with
5
votes
3answers
6k views

How can I stop vim automatically inserting a tab in CSS files?

When I am in a CSS file with a blank line, like this: and I want to simply make a new line and move down to it, by hitting Enter , vim is auto inserting a tab character, e.g. Running :set fo? ...
2
votes
3answers
90 views

How to change indentation in “case” with curly braces? [duplicate]

The default is this: switch(x) { case a: { y(); } } But I need this: switch(x) { case a: { y(); } } With :set cindent and :set cino={-s this is ...
9
votes
3answers
1k views

Vim switch statement cindent options

I want my C code indented as follows: switch (x) { case 1: break; case 2: { break; } } Instead of this: switch (x) { case 1: break; case 2: { ...
8
votes
6answers
6k views

How can I copy/paste new text without auto-indentation at every new line?

How I paste now: Right-click/Copy or simply highlight. Right-click/Paste or Middle Click or CTRL+SHFT+V Indents appear at increasing intervals: 0, 2, 4, 6, + Question at hand: From prior research, ...
0
votes
1answer
25 views

Fixing tab and space inconsistency

I used < in visual model to do a shift+tab reverse for a code inside loop after I removed the try/except phrase. Now, I get an error: $ python clean_captions.py File "clean_captions.py"...
2
votes
1answer
20 views

How can I have jinja2 indentation and syntax when keeping HTML filetype?

I have emmet installed and some more plugins that are usable on html filetypes, I would like to have syntax highlighting and have indentation for jinja2 while keeping the filetype HTML so my HTML ...
1
vote
1answer
25 views

incorrect auto-indent behavior

In some very specific scenarios, the auto indenter has almost unexplainable behavior that is very annoying. Example with haskell MultiWayIf syntax (cursor is at the "!"): test | test ...
2
votes
1answer
26 views

bad comment behavior in cmake files

When I'm editing a cmake file in (neo)vim I'm getting bad behavior block inserting comment characters. Given this section of text install_license_file( PACKAGE tomcrypt TARGET ...
1
vote
1answer
92 views

equalprg with lisp (clojure) and custom indent settings

How do I make equalprg match my custom indent settings? They are like: let b:did_indent = 1 set expandtab set shiftwidth=2 set softtabstop=2 set autoindent And they format the code to this (...
0
votes
1answer
31 views

How to have the cursor at the right indentation when editing PHP/HTML

When I'm working with HTML in a PHP file and I press enter while in INSERT mode, my cursor goes to the start of the next line instead of going at the right positive therefore I have to press tab to ...
2
votes
2answers
158 views

Format / Indent c++ as you type inside expressions

In visual studio, that code : for(int x=0;x<10;x++) {} becomes that code : for (int x = 0; x < 10; x++) { } as soon as you hit enter. I was wondering, is it possible, and if so, how can I ...
1
vote
1answer
88 views

Dynamically toggle formatoptions based on input

Question: Is there a way to control the indentation + comment leader input, when adding a new line? Details: I am trying to set formatoptions-=cro when inserting a new line (in specific syntax region)...
3
votes
3answers
100 views

How can I indent selected lines in Visual mode by space granularity instead of TABs?

How can I indent lines selected in Visual mode using space granularity instead of than TABs (i.e. < or >)? Sometimes when coding Python, I need to indent lines to a level that is not a TAB ...
1
vote
1answer
34 views

How to tell vim to ignore extern “C” brakets while indenting?

I have the following in my .vimrc to indent the whole file: nnoremap cu gg=G`` I have a problem using this in source files that have #ifdef __cplusplus extern "C" { #endif // code #ifdef ...
0
votes
1answer
11 views

vim plugin changes rust files to use a ts of 4 rather than 2

Let's say I have a simple file, echo -n "\tTABBED ONCE" > foo.rs And then I have in my .vimrc the following, set ts=2 call plug#begin('~/.vim/plugged') call plug#end() How come I open that file ...
0
votes
1answer
30 views

Is it possible to configure Vim to indent line continuation differently from indented blocks?

Here is an example of line continuation: ThisIsASuperLongClassNameWithALotOfExtraCharacters thisIsALongVariableName = ThisIsAModeratelyLongSuperClass.longFunctionCall( ...
0
votes
0answers
17 views

Is there a way to automatically reindent a selection while preserving relative indentation?

Suppose that I have a file that looks like this: aaa bbb ccc If I select lines 2 and 3 in visual mode and reindent with =, the result is everything in the same line: aaa bbb ccc Is there a way ...
1
vote
0answers
12 views

Get comments LINED UP in 65c816 asm syntax [duplicate]

I've been writing some 65c816 assembly lately. They have some interesting commenting conventions that I was hoping VIM could help me with. LDA $E7 ; You see, they BEQ IfZero ...
51
votes
6answers
44k views

How to add indentation guides/lines

In Sublime Text 2, you get vertical guides where your indentation is, like this: but in vim I obviously don't: Is there a way to show lines like that in vim? By the way, my indentation is 2 spaces. ...
1
vote
1answer
26 views

maintain alignment of text after folding

When a block of text is folded in vim, the first line of folded text is displayed in the foldline at a constant offset from the left edge of the window. Can the offset of that text be instead set to ...
2
votes
2answers
266 views

Is there a way to indent and outdent lines without moving the cursor?

I often escape insert mode only to change the current line's indent by pressing >> or << and then immediately go back to writing. I wanted to make this easier, so I included these lines on ...
1
vote
1answer
26 views

Vim autoindent and xml self-closing

(previously posted on https://stackoverflow.com/q/62000643/3206025 before I get that there is a Vi's SE) Here my vimrc filetype plugin indent on set autoindent set tabstop=2 set shiftwidth=2 set ...
0
votes
1answer
28 views

Using linebreak and other commands to customize vim indentation

I am using vim, by default I have not set the linebreak option in vim.So the following code: aug =ImageDataGenerator(width_shift_range=0.1,height_shift_range=0.1,horizontal_flip=True,fill_mode="...
1
vote
1answer
34 views

Vim plugin for different languages in one webfile

I have the annoying issue that I have a .php file with HTML, CSS, Javascript and PHP. I use Vim. But the autoindent is always messed up and only works for one language in the whole file. Is there a ...
0
votes
2answers
35 views

How to make the indentation more smart

I'm using vim to code and I set autoindent in my ~/.vimrc. Now, if I code as below: if (a == 1) {| // the cursor is here and I type ENTER } After typing the ENTER, the code becomes as below: ...
0
votes
0answers
16 views

How to prevent Smart-Tabs plugin from overriding youcompleteme tab completion

I've been looking for a solution to "tabs for indentation, spaces for alignment" and found that the Smart-tabs plugin does exactly what I want. However, when this plugin is active, it breaks the tab ...
7
votes
3answers
464 views

Is it possible to get the rule (cinoptions) that govern the indentation for a specific line in vim

I have the following code: namespace { template<typename T> struct One // This is the odd line { // impl details } template<typename T> struct Two { // impl details } }...
3
votes
6answers
704 views

Indent on New Line between HTML/XML Tags

I'm currently using imap <silent> <C-c> </<C-X><C-O><C-X><Esc>F<i as per this post and this page to close <></> tags of any kind with <C-c&...
1
vote
1answer
52 views

Reformat code: breaking lines and aligning on a character

I am writing code in R, specifically using the Tidyverse packages. There is extensive use of the pipe %>% to chain functions together. The lines become long, so it is recommended to break them up ...
2
votes
1answer
574 views

How to prevent Vim from automatically indenting new lines?

I use vim to edit a lot of latex files using vim 7.4. Some trick of the syntax indenting annoys me and interferes with my intentions. Particularly, the automatic indentation during the addition of a ...
1
vote
3answers
64 views

Create a mapping for a “smart” Home key

With other text editors, if you press Home, it first takes you to the indent, then all the way to the left. Is this possible with Vim?
31
votes
2answers
34k views

How to indent as spaces instead of tab?

I am coding some html templates in JADE files. I want to auto indent code with spaces instead of tab. I tried shiftwidth=2, tabstop=2, but no matter what, it's still indents using tabs instead of ...
8
votes
3answers
820 views

Shift left or right (with `noet`) without converting existing spaces to tabs

Foreword I'm using the "indent with tabs, align with spaces" ideology for indentation. This means that each line in a file can be prefixed with an arbitrary amount of tabs and spaces (as opposed to "...
35
votes
4answers
41k views

How can I change the indent size?

I just discovered I could indent and un-indent easily in Vi with : << and >> By default it adds a tab character. Now I'm wondering, could this be to a number of spaces via a configuration in my ...
1
vote
0answers
20 views

Autoindentation in .tex files

I use Vim to write Latex code and I would like to have autoindent when adding environments. I am aware of the smartindent capabilities that can be toggle on and off by inspecting the $VIMRUNTIME/...
2
votes
1answer
50 views

What option controls how much space is added after a new line?

When I set tw vim will auto wrap lines at tw. When breaking that line vim usually places some spaces to keep the indentation of the previous line. Example foo bar<suppose that a wrap happens ...
0
votes
1answer
37 views

Vim ignores `filetype indent off`

I don't have a personal vimrc. I use /etc/vimrc. The last 2 lines are: let testvar=999 filetype indent off I confirmed execution at the vim prompt using :echo testver, which displays 999. I tried ...
1
vote
2answers
52 views

Pasting text on Vim inside tmux breaks indentation

Ubuntu: 18.04 bionic tmux: version 2.6 VIM: Vi IMproved 8.0 (2016 Sep 12, compiled Jun 06 2019 ) Included patches: 1-1453 Modified by pkg-vim-maintainers@lists.alioth.debian.org Compiled by pkg-vim-...
1
vote
2answers
374 views

Auto-indent after carriage return after line containing open curly brace

I recently upgraded my Cygwin from a 2015 installation (5 years ago) to the current "2020" version. Gvim now automatically indents by shiftwidth columns when I press return after a curly brace { on a ...
0
votes
2answers
39 views

How to delete entry from indented argument from list?

Let's say with the cursor I'm on b in def f(a=1, b=2, c=3, e=4 ) and we want to delete the whole argument including the line break, so that we get def f(a=1, c=3, ...
3
votes
1answer
966 views

How do I disable intelligent indentation in HTML files?

I've created a blank example.html file and I open it in Vim, and I add the following contents: <div> Still in insert mode, at the end of the line, if I press enter, the new line will ...
2
votes
1answer
51 views

What is necessary to properly indent shell scripts with gg=G?

I was editing a small configure script and noticed that vim's indentation of the file was not working properly. A sample of the original source follows: while getopts 'dgSsx' opt; do case $opt ...
1
vote
2answers
127 views

Pressing Enter removes indentation

If I have a file a.js like this: let a1 = [ ]; and I press Enter at the end of the first line, a Tab is inserted. I do not want this, so I added a setting: filetype indent off but then if I have ...
6
votes
2answers
258 views

Deleting groups of autoindents in Insert mode

In my .vimrc I have set backspace=eol,start, which allows me to backspace over line breaks and the start of what I wrote since I entered Insert mode. This does not allow me to backspace over ...
0
votes
0answers
665 views

vim doesn't auto indent php files with html in it

In relation to this question: Auto indent turns off itself automatically on php files Vim has a php auto indent script; it behaves in following way: When autoindent is ON - if you open a php script, ...
2
votes
1answer
54 views

Keeping indent (like breakindent) when using hard wrap with textwidth

I know the breakindent option works with linebreak to preserve indent on wrapped lines. However, when I want to hard wrap lines (using the textwidth option so <EOL> is inserted when a line ...
0
votes
1answer
45 views

What vim setting determines the amount of indentation change by pressing > or < (greater than or less than)? [duplicate]

For me the > and < are set to 8 spaces. I would like them to be set to 4 spaces. What setting corresponds to this?
9
votes
1answer
611 views

Is there a setting to force a hanging indent on bulleted/numbered lists WITHOUT hard wrapping?

Basically, I'd like to have long entries for bulleted / numbered lists that automatically indent like so: 1. Congress shall make no law respecting an establishment of religion, or prohibiting the ...
2
votes
2answers
2k views

How do I make the yaml indent not indent lists?

OK so I would like to change the way that my yaml gets indented. Right now my vim indents a yaml list like this: list: - this - is - a list dict: this: is a dict I would like it to indent ...
1
vote
1answer
89 views

How to indent text between specific line numbers in vim?

Let's say I want to indent everything between lines 40 and 60 (both lines included). One way of doing this is to go to line 40 and indent 21 lines: :40 21>> I am slightly bothered by having to ...

1
2 3 4 5 6