Questions tagged [indentation]

Prefixing lines with whitespace to aid in readability.

Filter by
Sorted by
Tagged with
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
25 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 ...
49
votes
6answers
42k 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
24 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
248 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
25 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
26 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
32 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
34 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
11 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
450 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
631 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
51 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
546 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
61 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?
27
votes
2answers
31k 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
744 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 "...
1
vote
1answer
87 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 (...
30
votes
4answers
37k 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 ...
0
votes
1answer
27 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
1answer
123 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
83 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)...
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
47 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
32 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
48 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
232 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
38 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
926 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
87 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
243 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
658 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, ...
1
vote
0answers
35 views

How to disable auto-indentation while using vim-multiple-cursors?

I got familiar with vim-multiple-cursors recently and really enjoyed using this tool but one issue ruined the joy of using this plugin for me! To put it in a context, consider having an HTML file and ...
2
votes
1answer
42 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
593 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
84 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 ...
2
votes
3answers
108 views

Plugin to show enclosing indentation levels

I'm looking for functionality which may or may not exist. Basically, I'd like to have a location list split at the top of each writable buffer which shows the last line of each enclosing indentation ...
1
vote
1answer
53 views

Why does my line indent?

Please see line 20 and 21: My question is about how vim decides to auto-indent line 21, and how to adjust that behaviour. When I took this screenshot I had formatoptions=qrn1a set, however I believe ...
4
votes
1answer
166 views

Vim highlighting random indentations

As seen from the image, Vim decides to highlight those indentations for no reason. I've tried :noh and :set nolist (:set list seems to make it go away, but I don't want indentation marks) from a ...
1
vote
1answer
65 views

How to set custom shortcut in vim?

I want to make use of Shift+Tab to left-shift (unindent) a block of text, instead of Ctrl+d. How to do it?
1
vote
1answer
54 views

How to stop auto indent for some file with particular suffix

In my .vimrc file, I add few lines to it so that some file could have nice auto indent, such as .f90 and .c file, but it also cause autoindent for .plt file. Is there some way like if statement that ...
1
vote
1answer
30 views

Paste into a new line and preserve indentation

I want a mapping that does it. Apparently, it is not that simple. Because first, it might decide to keep it commented when I press o. And it behaves differently if it was copied by yy, insists adding ...
2
votes
2answers
54 views

Fix indentation in a file while keeping cursor on the same line

I'd like to use vim's builtin indent fix feature on an entire file. I have looked up answers, but all I found were suggestions to type gg=G, the only problem being that it brings your cursor to the ...
0
votes
2answers
57 views

Find and replace only between searched patterns

Editing large HTML file. Would like to do something like: :/<blockquote>/,/<\/blockquote>/s/^\(\s\s\+\)\(<[^>].\{-}>\)/\1 \2/g So basically just trying to indent all between ...

1
2 3 4 5 6