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

Questions tagged [indentation]

Prefixing lines with whitespace to aid in readability.

1
vote
2answers
31 views

What is valid use case for `smartindent`?

I might not have discovered everything about it, but the smartindent option has given me much more trouble than usefulness. For example, it indents a line beginning with for or if, and won't shift a ...
1
vote
1answer
25 views

Indenting a c file adds spaces before function's type?

Open a c file and then type: int main and then hit: gg=G It becomes int main Is this an intended behavior? Is there a way to change this? I prefer it to be retained as is because most ...
1
vote
1answer
19 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 ...
0
votes
1answer
25 views

LaTeX indent for \iff error in vim

With the minimal vimrc (with vimtex plugin): set nocp filetype plugin indent on syntax on set st=2 set acd set wildmenu set wildmode=longest,list,full let $USRPLUGD=$HOME.'\vimfiles\myvim\plugged' ...
1
vote
1answer
44 views

How to show 2 spaces as tabs in listchar?

I like to see my indentation level with listchars=tab:\|\ But one project uses two spaces instead. Is there any way to show indentation level lines then? This question seems to the opposite of Show ...
1
vote
1answer
42 views

Keep relative cursor position after indenting with >>

Can I setup >> to keep the relative cursor position? For example, assuming the line is def fun(<cursor>): can I make >> result in def fun(<cursor>): ? Obviously, with ...
0
votes
1answer
32 views

Copy and paste with breakindent set

I'm using breakindent to make long lines wraparound to the same indentation level as the start of the line. Unfortunately, with this setting on system copy and paste (in this case, out of the macOS ...
2
votes
6answers
63 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&...
0
votes
1answer
34 views

Automatically reindent lines filtered through formatprg

I have following xml file: <?xml version="1.0" encoding="UTF-8"?> <graph id="G" edgedefault="undirected"> <edge id="e6" source="n5" target="n4"> <data key="d1">1.1</...
1
vote
0answers
26 views

expandtab tab as 2 spaces show visually as 6 columns

How can 2-space indenting be shown as 6 column tab-style indents when editing, while remaining as 2-spaces? Background: a team uses a convention of 2 spaces for indenting code I prefer indenting of ...
1
vote
1answer
71 views

Incorrect auto-indent bash

Result of auto-indent in vim (filetype indent on) main() { case $1 in --ssh) echo "sshing into ${aws_ips[$1]}" ssh -i VPN_NODE_1.pem ${aws_ips[$1]} ;; --scp) ...
1
vote
1answer
43 views

How to stop “tab” key indenting whole line

In one version of VIM that I run, when I hit the "tab" key in insert mode, it indents the whole line, regardless of the cursors position in the line. Here is what I believe to be the only modified ...
0
votes
1answer
45 views

Indentation command `gg=G` for 'compressed' HTML doesn't unfold tags

Sometimes I copy 'compressed' HTML from TEXTAREA an I get code for ex. like this: <html><body><h1>header1</h1><p></p> <p></p> <div><p></...
1
vote
1answer
28 views

C++: different auto-indentation for function protoypes versus continuation lines

I have the following options setup for C++ and Python development in vim: autocmd BufEnter *.cpp setlocal tabstop=4 shiftwidth=4 softtabstop=4 textwidth=80 noexpandtab cindent cinoptions=:0,l1,t0,g0,(...
1
vote
0answers
33 views

How to get html tag auto completion?

I can't seem to figure out how to implement auto tag completion for html. Is there a plug-in or something else you guys use that works? Is there just one thing I can download that will handle ...
2
votes
1answer
257 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
92 views

NeoVim indents each property:value in CSS

I have a style element in an HTML file. When I type, NeoVim continuously indents each successive line: In my Vim, it works correctly: My vimrc. I would be grateful for any suggestion. Thanks!
3
votes
0answers
42 views

Make Vim ignore first character in line while indenting

Whenever I have to edit Perl Mason files, I always have problems indenting lines due to Perl code starting with %. For example: <div> <div> % if( !$something ) { <...
1
vote
2answers
82 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 ...
2
votes
1answer
33 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
84 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 ...
1
vote
1answer
61 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
2answers
52 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 ...
1
vote
3answers
119 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. ...
0
votes
0answers
36 views

How can I indenting/aligning nested hashes?

Is there a way to indent/align nested hashes. What I'd like is to be able to turn this: file { 'thing': one=> 'two', foo => { bar => 'baz', test => 'test', }, something =&...
0
votes
0answers
53 views

Compabitibility between vim and emacs style modelines

I'm a long-time vim user. Today I learned something new: modeline(s). For the many years, 15+, that I've used vim, I've handled this through autocommands for specific file types. Today, while ...
0
votes
0answers
20 views

Why does MacVim show `@` and blank space for long strings? [duplicate]

This drives me really insane... Say I have a short line of text on line 32, and a very long string on line 33, say 10,000 characters long... if I have word-wrap on, it ONLY shows line 32 and stops ...
4
votes
1answer
73 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
43 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)...
0
votes
1answer
57 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
108 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
134 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 ...
0
votes
1answer
271 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
34 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
93 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
0answers
33 views

After installing matchtag plugin my vim better look indentation is gone

vim default indentation is well. I like this. But when I install matchtag; this nice feature is gone. I don't know why. I removed matchtag but not come the previous nice look. see this current ...
0
votes
1answer
32 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
44 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
32 views

Indentation script not works for all occurence

I have following c.vim file - "imap ( ();<Left><Left> imap {<CR> {<CR>}<Esc>O imap [ []<Left> imap # #include<><Left> "imap " ""<Left> " ...
0
votes
2answers
35 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
45 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
69 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
57 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
86 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
158 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 ...
3
votes
1answer
284 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 ...
1
vote
2answers
80 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
0answers
114 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
131 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 ...
1
vote
1answer
150 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, ...