Questions tagged [indentation]

For questions about prefixing lines with whitespace to aid in readability.

Filter by
Sorted by
Tagged with
2
votes
1answer
244 views

Auto indent broken lines in html

Does anyone know what settings or package I can use to make vim autoindent html if it's wider that the screen. eg. it is displaying like this: <main> <section> <form action="#"&...
2
votes
1answer
597 views

How to disable automatic unindent of comments in Python?

I start vanilla vim8 $ vim -u NONE with these settings: :set ft=python :set smartindent :set cinkeys-=0# When I enter in insertion mode the following: Hello # The # is automatically ...
2
votes
1answer
437 views

Best Practices for working with an indent-sensitive language?

pug, and python are both indent-sensitive languages. I believe that if you have your editor correctly configured this can serve as an advantage, but if it is not correctly configured it's quite a bit ...
2
votes
1answer
59 views

Can't seem to get syntax information when in insert mode

This is for an indent function that should maintain the indentation should the cursor happen to be in a string region. It maintains the indentation when I hit == in normal mode but changes when I open ...
2
votes
1answer
850 views

jinja2 indentation with gg=G

I develop django templates, and I need to indent them with gg=G, but jinja2 tags seem to be immune to it. Here is an example of poorly indented, hard to read if-else tags: {% extends "base.html" %} {%...
2
votes
1answer
203 views

How does smarttab actually works?

Yes, I'm aware of what :h smarttab says, but I still cannot figure it out. " My vimrc set backspace=indent,eol,start set tabstop=8 " I always keep this 8 set shiftwidth=4 set softtabstop=-1 &...
2
votes
1answer
444 views

Vim doesn't use default indenting for markdown

My default indent width settings (4 spaces) are not used for markdown files. Whenever I open a markdown file it is indented using 2 spaces. Here are my default indent width settings. In my .vim/vimrc ...
2
votes
1answer
63 views

Automatically indent at the right level when moving to a completely empty line

I have this binding in my .vimrc to trick autointent into actually populating the next line with real characters, so that if I hit enter, leave the line, and click back to it, I can already be at the ...
2
votes
2answers
465 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 ...
2
votes
2answers
3k 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 ...
2
votes
1answer
3k views

Setting C++ indentation level?

I'm using basically the formatting of the Google C++ Style Guide. How can I configure neovim to use these settings for C++? On the other hand, for pure C, I would like it to use the BSD style. ...
2
votes
1answer
127 views

How to avoid indenting after a line that starts with a number?

I use Vim to write longer sequences of body text. It does automatic formatting, which generally works nicely. If I have a sentence that ends in a number, say a date or a year, and that number happens ...
2
votes
2answers
1k 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 ...
2
votes
1answer
109 views

automatic text wrapping messed up with parenthesis

I like to wrap my text to 80 characters all the time, even when I am editing Markdown. I have a problem when I open parentheses: it doesn't wrap right anymore. Since it is hard for me to explain it, ...
2
votes
2answers
103 views

How to re-indent nginx configuration based only on `{` and `}`?

I want to reindent an nginx configuration file with the following simple rudimentary rules: a { increases indentation a } decreases indentation The idea is cindent is just enough to do it. I have ...
2
votes
1answer
25 views

Indentation error on VHDL component instantiation

I'm finding some strange behaviour on indentation in VHDL, and have added a minimum example. It is very strange, as everything else seems to work perfectly with VHDL. Does anybody know how to fix this?...
2
votes
1answer
151 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 ...
2
votes
1answer
253 views

Creating a new indented line with a closing bracket below when hitting enter

I'm coming to Vim from VSCode. So far, it's been great although I've noticed I have some muscle memory movements that I've had trouble moving to Vim. When I write something like this (cursor is ...
2
votes
1answer
187 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 ...
2
votes
1answer
48 views

indentkey '}' triggers with delay?

I have several indentkeys (like end, elseif...), all of the works fine but typing } triggers the reindentation with a 1s delay. It behaves the same if I disabled my 'indentexpr' and use 'cindent'.
2
votes
1answer
403 views

Configure JavaScript indentation to indent keys object literals

I'm using vim version 8.0 on OS X (installed through Homebrew) and it keeps indenting object literals wrong. The first key and only the first key is flush with the previous line. All subsequent keys ...
2
votes
1answer
459 views

Trouble with vimrc

So I've been using Vim at school with a vimrc that seemed to be well set up, and learn few extra commands like set nu or syntax on. Right now I'm trying I'm using Vi on my computer, and was struck by ...
2
votes
1answer
74 views

Difference between autoformat and autoindent

What is difference between autoformat and autoindent? What are most popular solutions in text formating in vim of both of these methods?
2
votes
0answers
29 views

Reformatting a tab in vim [closed]

I am new to vim, and I'm facing an interesting problem. I need to reformat a file so that the indentation is consistent. How do I do this?
2
votes
0answers
371 views

How to prevent Vim to collapse a fold with foldmethod=indent on a text paste?

I have the foldmethod=indent setting, the problem with it is that when I'm pasting a line or lines before the first line of a fold and all of these lines have the same or a greater level of ...
2
votes
0answers
234 views

vim auto indent suddenly stopped working

Recently, neovim auto indent was working fine, but suddenly it stopped working. here is my ~/.config/nvim/init.vim:- call plug#begin('~/.local/share/nvim/plugged') Plug 'townk/vim-autoclose' Plug ...
2
votes
0answers
510 views

Is it possible to color vim vertical indentation lines depending on the indentation level?

I'm using vim 8. In the attached picture you see yellow vertical lines that indicate the indentations of a code. Is it possible to color depending on their indentation level? E.g. all vertical ...
2
votes
0answers
120 views

Can someone explain the strange behaviour with indenting during reformatting?

Recently, someone noticed a strange behaviour with indenting during formatting with my LaTeX plugin, vimtex. I've researched it, and I've ended up creating a minimal example. Load the following code ...
2
votes
0answers
64 views

Structural navigation by indentation level [duplicate]

Suppose I have a pretty-printed JSON file that I'm trying to navigate and my cursor is at the X position. Is there a motion to move to the nearest line above/below the current one with an indentation ...
2
votes
0answers
354 views

How do I fix indentation after multiline c++ initialization list?

When I have a long constructor that forces me to put initialization list items on separate lines, my indentations look like this after gg=G. Really_Long_Class_Name::Really_Long_Class_Name(int _arg1, ...
2
votes
0answers
392 views

Make vim version 7 edit xml files

I'm using old Debian linux an vim version 7.1.314. I would like to edit eclipse .cproject file that build using XML syntax. Currently vim shows not colored information. I found vim plugin that I hope ...
2
votes
0answers
90 views

Automatically determine whether to use spaces or tabs [duplicate]

I like to use tabs for indentation (hey, don't bully me!). But 33% of other programmers prefer spaces. The norm with Python is to use spaces for indetation. Even so, I configured Vim to use tabs with ...
2
votes
1answer
968 views

Vim indentation for html files

Most of my edits are done in .html files. However, I write a lot of jinja code and css in these html files. Problem 1: Jinja Indentation whenever I have a bloc such as this: {{ my_macro(arg1, arg2, ...
1
vote
1answer
10k views

Automatic whitespace in python

I'm a novice in Vim and configuring it for writing python scripts comfortably. Is the a way to automatically put four spaces after I jump onto the first line of while True: loop ?
1
vote
1answer
1k views

No shiftround when hitting Tab

I'm having trouble making indentation work as I expect in Vim. Short version: What I want is to disable Tab mark. Long version: What I want is to ALWAYS insert four spaces when indenting (i.e. when ...
1
vote
2answers
934 views

Vim, erasing multiple spaces used as indentation

I've been struggling with this topic for a little more than i'd like to admit but here it is: I've set my vim (~/.vimrc) to indent using 4 spaces using :set expandtab :set tabstop=4 :set shiftwidth=...
1
vote
2answers
565 views

repeat indent-to-previous-position in vim?

I very often want to do the following or similar: indent all lines from previous position to current position inclusive repeat, repeat, repeat (to further indent the same lines) I feel I should be ...
1
vote
2answers
468 views

Vim indentation of a bash script seems broken after a pipe

Vim builtin indentation seems to get confused with the following script. I cannot get Vim to indent properly the while-loop after the pipe. #!/bin/bash while true do # while loop is indented ...
1
vote
1answer
168 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
vote
2answers
1k views

Keep the full visual selection after indenting in easy mode vim

What is the best way to indent multiple lines in insert mode? Here is what I have currently: vmap <Tab> > vmap <S-Tab> < The problem is that it doesn't properly handle selection ...
1
vote
1answer
575 views

Indentation-guides in vim with pure .vimrc-magic (no plugins allowed)

I'm on a server, and the server-administrator are really conservative about what I put on that server. It took bottles of wine, just to be able to put a .vimrc-file on there - so in order to install a ...
1
vote
1answer
44 views

Indenting now add suspicious chars to my files when pasting

Following answer I got there to allow >> to indent, I edited my .vimrc to this: :set shiftwidth=2 :set autoindent :set smartindent But now when I copy/paste (via putty), it indents incrementally, by ...
1
vote
1answer
48 views

Inserting abbreviation from file

First, I apologize if this is a trivial question. I have the following file (main.ab) defining a Python snippet: def main(args): ... if __name__ == '__main__': args = ... main(args) And ...
1
vote
1answer
36 views

Replace two space indentation with tabs

I'd like to replace all two-space indents with tabs I can't do :%s/ /^I/g bc this replaces within lines too. I can't do :%s/^ /^I/g bc this replaces only the first two spaces of each line, not each ...
1
vote
1answer
66 views

Stop vim from deleting expanded tab as a block of spaces

I am on CentOS 8.1 and using vim 8.0.1763. When I open a python file, e.g. vim tmp.py, I type tab and it inserts 4 spaces (see .vimrc below). When I type delete, it deletes all 4 spaces. I want it ...
1
vote
1answer
87 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 ...
1
vote
1answer
38 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 ...
1
vote
1answer
51 views

What setting causes my autoindent to add indent on a new line?

I have this go code snippet that I am working on in vim with vim-go enabled. | is where my cursor is at. // PlayerServer is a HTTP interface for player information type PlayerServer struct { ...
1
vote
1answer
59 views

Indent text to beginning of line

Sometimes I'll have some text with an arbitrary indentation. Sample text. If I want to bring this text back to the beginning of the line, I'll visually select the line and then ...
1
vote
1answer
109 views

How can I adjust ='s alignment of C-style comments?

I'd like = to indent block C-style comments like this: /* Comment. */ not this: /* Comment. */ Note the extra space before the last *. (I would like to automatically align the first / and the ...

1 2 3
4
5
7