Questions tagged [indentation]

Prefixing lines with whitespace to aid in readability.

Filter by
Sorted by
Tagged with
2
votes
1answer
211 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="#"&...
1
vote
1answer
463 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, ...
2
votes
1answer
409 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 ...
3
votes
2answers
3k views

Keep \t Characters, While Don't Transform Spaces to Tabs?

In Vim, how to change the vimrc so that I could keep files' \t characters while I don't want \t characters appear in the newline generated by auto-indentation and tab-button I pressed. Is this ...
44
votes
5answers
36k 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. ...
0
votes
1answer
182 views

indent an existing unindented file as per some indentation commands supposedly written for autoindenting new files

I have created some indentation commands like set shiftwidth=4, set autoindent and so on.... in my .vimrc file in my home folder and I'm able to get new files auto-indented happily. What I want to ...
9
votes
2answers
6k views

vundle “filetype plugin indent on” messes with tabwidth

I installed vundle yesterday and since I did, the tabwidth I configured in my vimrc is ignored and set back to 4 instead of 2. I found out that the following line after the vundle paragraph is ...
0
votes
0answers
602 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
2answers
484 views

Auto indent turns off itself automatically on php files

I don't get it, my vimrc has set ai, but when editing project files (php), :set ai? always returns noautoindent inside .vimrc :set ai? returns true. my rc: " vim-plug (https://github.com/junegunn/...
4
votes
1answer
1k views

Search and replace, special pattern for indent (ex: newline = '\r')

I am cleaning up some minified css. I found this article helpful for adding a newline before/after a search match. This SO thread has a pretty exhaustive list of ways to indent with VIM, but it DOES ...
4
votes
1answer
152 views

multi-line insert after indentation whitespace

if I have a list of indented text test test test test test test test test test test test test test test and I wanted to convert it to a markdown list - test test - ...
2
votes
1answer
312 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 ...
5
votes
1answer
439 views

Why is line continuation is indented with 12 spaces in vimscript?

let b:some = { \ 'some', \ 'array', } This makes code ugly IMHO, how can I change that and should I change that? Is that some coding style or something in vimscript? Also, is ...
6
votes
1answer
638 views

How to show trailing spaces, while leaving tabs as they are?

I like the ability to show trailing whitespaces, so I have this setting. set list listchars=tab:\ \ ,trail:· I never use tabs (although I don't think tabs are bad, it's just a convention), but ...
6
votes
0answers
618 views

Mixed PHP and HTML indenting

Is there a way to have mixed indenting more like Sublime Text (left) than Vim does it? I would like the nested UL to follow the (line 10) to follow along the (main indentation).
5
votes
1answer
176 views

Keep beginning of current fold on top of the screen

I've googled around but can't find anything about this. There is a case: when I navigate deep down through large blocks of code in (for example) python, it would be useful to see which method, ...
2
votes
1answer
150 views

expandtab not replacing tabs after space separated characters

Running vim with the following settings: expandtab tabstop=4 softtabstop=4 shiftwidth=4 And no other user plugins. In insert mode... If I enter: a<Tab>b<Tab>c all tabs are replaced ...
0
votes
1answer
127 views

Control indenting of Ruby Comments

I use Vim to edit Ruby code, and the one issue that I keep having trouble with is the comment indenting. It seems that Vim really wants all # comment marks that begin a line to indent all the way to ...
2
votes
1answer
467 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 ...
39
votes
1answer
22k views

What is the difference between `filetype plugin indent on` and `filetype indent on`?

I see one of these two lines in .vimrc files. This one seems to be most common: filetype plugin indent on But how does it differ from this line: filetype indent on I've found documentation for the ...
3
votes
1answer
2k views

Vim indent using “=” inserts 2 tabs

If I try to indent a code using visual mode or ggVG= vi automatically inserts 2 tabs instead of just 1. for example: // inside main for (int i = 0; i < 10; i++) { test += i; } changes to: ...
2
votes
1answer
744 views

Autoindent second line of plain text bullet list item

When using plain text I write bullet lists like this (second and further lines indented with two spaces): * blah blah blah blah blah * yadda yadda yadda Problem is, when I start out a new bullet ...
2
votes
1answer
801 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 ...
12
votes
1answer
816 views

Why does >3k move the cursor up when >3j does not move it down? [duplicate]

Hitting >3j indents the current line and the three below it, and >3k does the same but with the three lines above. However, when indenting down, my cursor is left on the same line as it started, ...
4
votes
1answer
298 views

Set tabulation size when function's parameters are written on multiple lines

I need to respect a coding style with 4 spaces tabulations and I want to fit with the 80 columns rule. I get then the case where some function need their parameters written on several line : int ...
6
votes
1answer
990 views

How can I indent JavaScript that's within <script> tags in an HTML file?

If I am viewing a HTML file that someone else wrote, it often has <script> tags containing javascript, e.g. <!DOCTYPE html> <html> <head> </head> <body&...
9
votes
2answers
339 views

Indent to next indentation level with >>

From time to time I have to work with code that isn't indented to the level of indentation I have Vim set up to (4 spaces per level), usually after copy/pasting something in the file. I usually make ...
37
votes
1answer
21k views

What is the difference between autoindent and smartindent in vimrc?

I read the wiki entry on vim source code indentation I still can't understand the difference between autoindent and smartindent It seems they do the same thing, copy the indentation level to next ...
1
vote
1answer
264 views

Vim indent rules apply to existing files but not to new ones

vim-erlang-runtime is set up for indenting Erlang files that works for already existing files and does not work for any newly created ones. To elaborate, when starting a function body whenever I ...
1
vote
2answers
138 views

How do I keep folds when formatting (reindenting) the whole file?

I do quite often use this mapping: autocmd FileType cpp nnoremap <buffer> == :%!clang-format -style=file<cr>2g;zz It reindents the whole file and returns the cursor to the last edit ...
6
votes
0answers
737 views

What is the best practice in vim8 for wrapping with indentation aka breakindent

To have proper paragraph wrapping with indentation in vim (after vim7.4) we could use this: " Wrap the text with identation isntead of the old way set breakindent set showbreak=\ \\_ Since vim8 ...
0
votes
2answers
231 views

How can I highlight misuse of tabs and spaces according to current configuration?

I'm looking for a way that will highlight lines (or part of lines) that don't adhere to current tabs settings. Say for instance, I have the following configuration in my .vimrc tabstop=8 ...
5
votes
1answer
5k views

incorrect auto-indent in bash code

I have bash script which Vim detects as a sh according to :set filetype?. In addition, Vim-script for auto-indention support for shell-scripts(/usr/share/vim/vim74/indent/sh.vim) is also present. ...
2
votes
1answer
362 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 ...
4
votes
1answer
186 views

indent command does not indent matched lines

I have file where I would like to indent all the lines between curly braces: html { margin: 0; padding: 0; border: 0; font-size: 100%; font: inherit; vertical-align: baseline; } body { line-height: 1....
1
vote
0answers
268 views

Fix indentation after a multiline HTML tag

I have the following in .vimrc: set tabstop=2 softtabstop=-1 shiftwidth=0 expandtab filetype plugin indent on When I type the following in an HTML file: <html id="somethingverylong" > <...
3
votes
2answers
234 views

Create a new line with indentation matching the cursor position

I am looking for a way to create a newline with an indentation equal to the current column position of my cursor. Here is an example. Say I'm editing some line of code looking like this, with my ...
2
votes
1answer
723 views

Key binding for enter key in insert mode

I want to be able to run a script to indent the line of code I have just written each time I press enter key in insert mode. More concretely,currently I use following key binding: map <C-K> :...
2
votes
1answer
350 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 ...
1
vote
1answer
43 views

How to prevent indent, unindent (>>, <<) from re-aligning text?

Is it possible to make indenting/unindenting not re-align text, eg: /* * Some Text */ Indents to: /* * Some Text */ I would prefer/expect: /* * Some Text */ I saw ...
1
vote
2answers
323 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
0answers
150 views

Why does cindent align statements to closing } in switch case?

I prefer this indentation style for switch cases with local variables: switch (expr) { case CONST_BLAH1: { int decl; // scope local to this case stmt; break; case CONST_BLAH2: ...
2
votes
0answers
113 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 ...
4
votes
2answers
997 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: { ...
1
vote
0answers
99 views

What controls (de)indenting when inserting a brace character?

Working on a C file, Vim correctly indents as I type. In Objective-C, however, it gets indentation right, but deindentation wrong for instance methods, unless I exit insert mode and use the = operator....
2
votes
0answers
57 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 ...
3
votes
4answers
2k views

Delete indenting spaces one at a time

I want to be able to delete indenting spaces one at a time. If I set shiftwidth to 4, it deletes 4 spaces at a time if vim counts them as indentation. Setting shiftwidth to 1 fixes the problem, but ...
5
votes
2answers
622 views

Vim conceal indentation. Replace indentation spaces with utf-8 chars

I use four spaces for indent. I would like to replace the indentation with some UTF-8 chars. What I have: 1. def foo(bar): for jaffa in bar: print jaffa 2. var foo = function(bar){ ...
1
vote
1answer
358 views

“shell returned 2” when I try to indent

I have a server with vim installed and an empty .vimrc. I open a python file and run :set filetype=python. I then try to indent a line with == and vim complains: :.!indent shell returned 2 Press ...
5
votes
2answers
4k 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? ...