Questions tagged [indentation]

Prefixing lines with whitespace to aid in readability.

Filter by
Sorted by
Tagged with
2
votes
1answer
44 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
243 views

vim suddenly stops indenting and uses tabs instead of spaces

every now and then my neovim just stops the correct indenting and i have to restart the session. Besides the indenting, some plugins seem to stop working as well as some built in function like the o ...
2
votes
2answers
1k views

How to disable bad indentation when pasting text?

I am using vim and simply want to disable auto indent when I paste text into my terminal vim session. I have tried numerous solutions including various incantations of below to ~/.vimrc: set nopaste &...
3
votes
4answers
590 views

How can I easily indent inline comments?

I frequently have inline comments for variables: var1 = 0 # Var 1 var2 = 0 # Var 2 var3 = 0 # Var 3 var4 = 0 # Var 4 (This is in python, for example, but this question applies to C-Style ...
2
votes
4answers
546 views

Paste in normal mode ignores autoindent

When I paste something within normal mode, vim ignores autoindent. I copy and paste with y and p. As mentioned autoindent is on. It works fine when I manually indent or type something before pasting. ...
7
votes
1answer
485 views

Automatically apply indentation using spaces or tabs

I often edit different files in vim, some of which use tabs, and some and different amounts of spaces. With this, I have not found a combination of set expandtab, set shiftwidth, set softtabstop, and ...
1
vote
1answer
101 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)...
2
votes
1answer
444 views

Trigger reindentation after snippet has expanded to word in 'indentkeys'

The ftplugin vimtex provides the file indent/tex.vim with following line setlocal indentkeys+=[,(,{,),},],\&,=item,=else,=fi 'indentkeys' 'indk' string (default "0{,0},:,0#,!^F,o,O,e") ...
4
votes
1answer
355 views

Why does the “rst” filetype automatically indent subsequent list items?

I've been having trouble understanding the behavior defined in GetRSTIndent() in indent/rst.vim. I'm specifically using Neovim v0.2.2, but I believe this file has not changed between Vim/Neovim. ...
1
vote
0answers
323 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
1answer
3k views

How to unindent code blocks?

For indenting there's no problem. I enter the visual-block mode, select the block, enter insert mode, press ctrl-t (or just press tab), exit the visual-block mode, and the whole block is indented. ...
1
vote
0answers
50 views

Autoindent with minimal indentation

For some reason, Vim started to indent JavaScript in this crazy manner. I bet it's related to some settings in my syntax plugins, but I can't seem to figure out which ones are causing this behavior: ...
0
votes
1answer
359 views

How to change the size of the indent that's created using “>” (forward arrow)?

If I want to change the tab size, I can do that with set tabstop=<number>. I have that in my .vimrc to make it 4 instead of 8. However, when I indent/deindent text by highlighting it then using ...
0
votes
1answer
64 views

Disabling indentation for filenames without suffix

VIM's Wikia documentation states that you can disable indentation for certain filestypes by inserting the line let b:did_indent = 1 in the file ~/.vim/indent/<filetype>.vim where <filetype&...
1
vote
1answer
86 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 ...
0
votes
1answer
41 views

Indentation script does not work for all occurrence

I have following c.vim file: imap {<CR> {<CR>}<Esc>O imap [ []<Left> imap # #include<><Left> command F %s/\v(\w) ?(\+|-|\*|\/|\>\=|\<\=|!\=|\=|\=\=) ?(\w|-)/...
0
votes
2answers
80 views

Vim: Aligning insertion point with left side of column

Suppose I have this (where my insertion point is designated "|"): col1 col2 thing oeueaoue| another something test What keystroke(s) would I use so the insertion point jumps to ...
1
vote
0answers
398 views

Set tab width according to file [duplicate]

I have the following in my .vimrc: set expandtab "Use soft tabs (spaces) set shiftwidth=2 "Set tab width = 2 set softtabstop=2 "Set tab width = 2 set autoindent "Set indent of previous line Now if I ...
1
vote
1answer
502 views

Auto-indent with spaces, but insert TAB when I press the TAB key

I like to indent my shell scripts with two spaces instead of a TAB. So, I set setlocal shiftwidth=2 in ~/.vim/after/ftplugin/sh.vim. It works, but I noticed that when the indentation level gets ...
0
votes
1answer
66 views

Going to newline pulls existing code to beginning of line

I'm not that experienced with vim. I've been working with some html/php in macvim and there's this annoying behaviour that I don't know how to control. See below. x denotes the current position of the ...
1
vote
2answers
268 views

How to indent bash code with neovim?

I just installed neovim. But I not sure how to auto indent bash code. I have vim configured so that it can autoindent code. My ~/.vimrc has the following code. But it seems that they will not be ...
0
votes
1answer
420 views

Pseudo-Indent (two spaces) Multiple Lines

Basically, I need to indent a block of R code. Unfortunately, vim's tab size is bigger than the two spaces that I'm using. Is it possible to accomplish this without hitting the space bar twice for ...
4
votes
1answer
814 views

How to change indenting for html files?

I code mainly in 2 languages python and HTML. I currently have the indenting configured for python in my neovim configuration file but I would to know how to make neovim auto-detect the type of file ...
2
votes
2answers
297 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 ...
2
votes
0answers
219 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
420 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
1answer
475 views

Set Indentation when Declaring Constructors for C++ Classes with Inheritance

I've been using vim for two years but there are many things I don't know very well. Today, I was coding in c++ and found that I wanted to type the snippet like this: Horse(COLOR color, HANDS height, ...
1
vote
2answers
767 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=...
0
votes
1answer
48 views

Don't reset vim tab to the beinning line

I have a question about tabs within vim and I'm using VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jan 17 2018 20:33:56) Included patches: 1-1255 Compiled by _pbuild@amd64.ports.openbsd.org tab ...
2
votes
1answer
2k 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. ...
0
votes
1answer
54 views

sublimetext vintage mode, vs VIM trying to find a substitute for a shortcut key [closed]

So in vim usually I press v j j j > esc then gv to reselect so that I can indent a couple of lines. How can we reselect in VI?
3
votes
1answer
230 views

Indenting schema, is there a sort of thing you can load/configure into “=” in vim?

I don't know what vim cannot do, so far, I feel it is so powerful! I need indent in Normal Mode for c++ code. I found vim is using "=" to that, just visual/mouse select the code and hit "=" key, or ...
3
votes
1answer
161 views

Does each indention option override the previous one?

From :h indent.txt: ...each one overrides the previous if it is enabled... Now if I set 'cin' after 'ai', Does 'cin' disable the effect of 'ai'?. If no, so what is the purpose of "override" ...
1
vote
0answers
1k views

vim autoindent not working correctly

This is what I have in my vimrc: if empty(glob('~/.vim/autoload/plug.vim')) silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/...
0
votes
1answer
908 views

Differences between indention options

I have read 'ai', 'si', 'cin', 'ci' help pages in Vim but I still cannot realize that what indention option is good for me. Yes, I can read that :help pages again and set whatever I need in my vimrc ...
2
votes
2answers
222 views

Is there a way to hide leading whitespace?

Some of the files I am editing have a huge amount of whitespace leading before each line, for example: module Something module Inside class FinallyClass def ...
0
votes
1answer
370 views

`smartindent` indents four tabs?

I'm just looking for a very basic indentation scheme. In .vimrc I have :set tabstop=2. Adding :set smartindent has the effect of indenting the code by four tabs, very strange? A single tab the size of ...
3
votes
2answers
314 views

How to change the displayed indentation amount?

You and your collaborators have different preferences for how to indent your files. Obviously they have a barbaric suggestion, whether that's tabs, spaces or something else, doesn't matter, it's ...
4
votes
2answers
417 views

Paste word on new line with indentation from current line

Using ]p in normal mode, I can paste a yanked line of text on a new line below the cursor with indentation equal to the current line. Using the :put command, I can paste a yanked word as if it were a ...
1
vote
1answer
104 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 (...
2
votes
1answer
188 views

Preserve indentation in C++ comments

Is it possible to configure vim and cindent to not alter indentation in c++ comments when reindenting the file (gg=G) ? I have some formated lists in comments aligned with 4 spaces but vim interpret ...
2
votes
1answer
126 views

Split a block to multiple lines with respecting indenting

Context is Ruby. Lets say I have a long line which has a block which I want to have simply in multiple lines: let:(variable) { do.some.stuff(expressed_as_a_long_line { x }) } I'd like split this ...
3
votes
1answer
68 views

How do you get two `match`es at the same time to work? [duplicate]

I have two match lines in my vimrc. they work when they are used by themselves but when i try to uncomment both i don't get any matching behavior: " highlight spaces used for indenting match Visual /^...
0
votes
1answer
266 views

How to change 4-space indentation when using "kotlin-vim` plugin [duplicate]

I just installed kotlin-vim plugin. The plugin looks like using 8-spaces indentation. How can I change it 4-spaces indentation? (To indent all codes I used gg=G. Maybe I'm using wrong way for indent ...
1
vote
2answers
253 views

Duplicate indentation of current line

Some console editors distinguish between "inserting a newline" and "inserting a newline + matching the level of indentation of the current line". For instance, the editor mg distinguishes between C-j ...
1
vote
2answers
594 views

How to move to same indentation as previous line

Suppose I have many lines of various indentations. E.g. qqqq wwwwwwww eeeeee rrrrrrr tttttt yyyyyyy If I am anywhere on the fourth line above which is blank. Is there a ...
1
vote
1answer
820 views

Strange behaviour in Regex, double escape backslash

I've tried to debug an indent function i've written, and came over this strange behaviour. Here I try to detect some LateX tags (debug output): >echo previous \label{ch10.1} >echo previous =~ "\...
3
votes
1answer
272 views

autoindent different from manuall indenting

We have a custom filetype at work which I use with a plugin i've written. There we have a construct like this: \item some text. it is indented on level more than the \item tag \item the next item ...
5
votes
1answer
497 views

Indentation in Latex within a list after an equation

Here is a minimal .tex file: \begin{document} \begin{itemize} \item Here is an equation: \begin{align*} x = y \end{align*} \item Here is another item ...
1
vote
0answers
174 views

Vim enum indent for C++

When I use auto indent in vim, it almost working correctly, but in C++ 's enum, it have some problem like this: It should be like this: My indent settings: set expandtab set tabstop=4 ...

1 2
3
4 5
7