Questions tagged [indentation]

Prefixing lines with whitespace to aid in readability.

Filter by
Sorted by
Tagged with
5
votes
2answers
976 views

HTML is not being indented

I have just created a file .html. When I run set filetype? I get filetype=html. Then I select this code: <div> <span> </span> </div> and press = but the code is not indented.....
4
votes
3answers
463 views

How can a character be inserted during an edit session by its Unicode numeric value?

I'm trying to set up a plugin to enable indentation guides, following an answer to this question. The plugin is Yggdroot/indentLine. It has instructions to set up a custom glyph to be shown instead of ...
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 ...
3
votes
1answer
854 views

How to make auto-indentation work correctly after macros ending with semicolons

I'm using cindent with C++ sources, and when I put some macro, which already ends with a semicolon, like Qt's Q_OBJECT, cindent doesn't understand it and makes an extra indentation on the next line. ...
5
votes
1answer
631 views

vimrc tab behavior when noexpandtab and softtabstop is less than tabstop

Questions In the following example: Why in the first line, a \t is inserted but only 4-col blank is displayed? Shouldn't it be 8 according to tabstop? Why the two <TAB> hits in the first line ...
5
votes
1answer
717 views

Vim auto indentation

I am using Vim with Pathogen, vim-jsx, and vim-javascript. I have trouble getting the correct indentation. When I am breaking one line that is too long into several pieces (without adding new blocks),...
8
votes
3answers
493 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 } }...
42
votes
1answer
31k 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
480 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 ...
15
votes
1answer
885 views

How to move the cursor to the correct indentation level without quiting insert mode?

For example I have this JavaScript code. The | character represents the cursor position and it is on an empty line. function a() { console.log("a"); function b() { console....
4
votes
4answers
2k views

Why is autoindent not applied to my markdown files?

When editing markdown (*.md) formatted files, and making bullet points, upon pressing return I want the new bullet point to be automatically created in the same level under the previous one. ...
13
votes
1answer
1k views

Unexplained gq indentation issue

I insert this text in Vim: t tttt ttttttttt tt tttt tt ttt tttttt-tttt-ttttttt tttttttttttttttttttttttttttttttttttttttttttttttttttttt ttttt ttt ttt tttttt ttttttt tttt ttttttt: ttttttt tt ttttttt, ...
4
votes
2answers
754 views

Remove unecessary indents while keeping the relative indentation

I am looking for a transformation that would change this text: text indented text double indented text indented again to: ...
4
votes
1answer
905 views

Indenting c/c++ using lisp indentation style

I want to write c++ code in vim using lisp indentation style (closing curly braces on the same line as last statement) but I can't figure out how to configure indentation to use that style. Is there ...
5
votes
1answer
266 views

When moving text to new line, changes indentation for both lines

I am seeing this in Vim 7.3. I have autoindent on. Sometimes, when I move some code to the next line, the indentation of the line it was originally on changes, and then the newly created line is set ...
1
vote
1answer
220 views

How to use 'filetype indent on', without it indenting while entering text in insert mode

I'm using filetype indent on in my vimrc, generally this works very well, when pressing return it sets the indentation properly (in most cases). However it has a very strange/annoying behavior, of re-...
10
votes
1answer
176 views

How to temporarily make gq consider hyphen (-) a normal word, to not indent the following lines in the same paragraph

I have tried this in a JavaScript file after disabling smartindent and autoindent options, with textwidth = 80, but it is still the same. It also happens automatically because of the textwidth option ...
1
vote
1answer
435 views

Autocomplete popup menu with autoindent and hard wrap in insert mode

I have set autoindent and set tw=90 and set fo=t. Additionally I have working autocompletion that means when I type one character a popup menu come in. Because of popup menu in some situations, where ...
3
votes
0answers
131 views

Formatting blocks of “commented out” text

I would like to be able to edit and format blocks of comments (in different markup and programming languages) as if the commenting characters (generally in the beginning of the lines) are ignored. ...
6
votes
3answers
10k 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? ...
2
votes
0answers
88 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 ...
1
vote
1answer
122 views

How do I choose which indent format to use for same file type?

I have multiple indent rules for same file type. I'd like to try them separately. How do I see which one is active? :set filetype is correct. I did manage to change the rules by disabling all other ...
3
votes
1answer
424 views

Auto Indent (the = key) of C switch block

For the following switch block: If I select the switch block and apply the auto format command, the = key, I get the following: The block is formatted correctly in the first image, but it gets ...
1
vote
0answers
25 views

Parentheses off the page stop being recognized

I am using a recorded macro to manually wrap an extremely long string in a python script, like this: blah = ('blahblah ... blah blah') to blah = ('blahblah...' 'blahblah...' ... ...
1
vote
0answers
57 views

filetype plugin not loaded on files opened with edit command

I've turned on filetype indent and plugins on with the following in my vimrc file: filetype indent plugin on Everything is fine when I open a file from terminal, but if I open another buffer ...
9
votes
1answer
401 views

Disabling partial HTML indentation in Vim

Caveat: I'm not a web developer. That being said, there are rare occasions where I have to edit HTML. When I do, I've noticed a behavior in Vim that I don't like, and hope that I can change via ...
5
votes
1answer
65 views

Adding new characters cause splitting line into many lines

I'm analyzing a lot of logs using VIM version 7.3 (2010 Aug 15, compiled Sep 24 2013 13:45:11). Recently I obtained logs that look like this: 3521:2015-09-28T09:18:36.922557+00:00 192 [info] » ...
3
votes
1answer
478 views

Why `v:lnum` doesn't return 1 for the first line?

I really want to know why doesn't Vim's v:lnum return 1 for very first line. I tried googling and searching in Vim's docs, but I can't find an answer. I understand that v:lnum returns line number, ...
2
votes
1answer
2k views

vim indentation setup - Ruby [closed]

I have a problem with indentation using vim. Lets say I have a file: class My end // <-- cursor is here When I press O vim will create new line in between class and end and it will be indented. ...
10
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 ...
2
votes
1answer
809 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
172 views

`normal` does not seem to allow automatic indentation

Why does this not work as expected? function! MyO() normal! o endfunction nnoremap TT :call MyO()<cr>i If this is the situation: | an indented text ^ (normal mode) typing o gives: ...
3
votes
1answer
411 views

How to skip over indentation whitespace with horizontal motion?

I have a file that uses 4-space indentation. By default, when I move horizontally, Vim moves over those spaces one by one. How can I configure Vim so that it moves 4 spaces horizontally when moving ...
37
votes
2answers
42k 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 ...
3
votes
0answers
228 views

Is there a way to add handlebars to html.vim?

I'm working with handlebars right now and I'd like to get tags like: {{#component 'whatever'}} {{/component}} and {{#if}} {{else}} {{/if}} to increase the indent count. Unfortunately, it doesn'...
9
votes
2answers
1k views

How do I prevent Vim from unindenting empty lines?

Vim keeps unindenting the lines I want to keep indented if I don't write anything on them... I'll give an example, where the | is the caret. Caret is indented and I press enter if expression: ...
0
votes
0answers
180 views

Using single quotes blows up syntax formatting in .js

Just noticed that using single quotes in javascript blows up automatic formatting sometimes: See the public/sass/*.sass line: Double quotes: gulp.task('compile-sass', function(){ gulp .src("...
5
votes
1answer
83 views

Auto-indenting copied text

I would like to auto-indent text blocks that I have just put. At a minimum, I would like to retab the new block of text, since otherwise I sometimes end up with tabs in files that shouldn't have tabs ...
5
votes
1answer
486 views

Count the number of whitespace in the beginning of a line

How to count the number of whitespace in the beginning of a line ( aka indentation ). eg: foo() foo() And then :command(2) 4
1
vote
1answer
84 views

Search for continuation line

How to search for continuation line, as detected by c-indent in vim ? ie. the +N cinoption.
7
votes
2answers
3k views

How can I fix the auto indentation in LaTeX?

Vim has some fancy pants indentation stuff. When it works right it's a pleasure to have, but sometimes it just drives me nuts. One that I've never been able to solve has to do with LaTeX syntax. Lets ...
5
votes
1answer
870 views

Indentation of preprocessor directives

In my vimrc I have the following line, which figures all the indentation of my files. filetype plugin indent on When writing C programs sometimes I use preprocessor directives like #ifdef foo and #...
11
votes
1answer
615 views

How do I shift the line indent to a specific value?

Many times I run across a situation where a line is not indented properly. Ether through a paste, bad / not preferred indent plugin, or most often extra spaces offsetting the indent value. I usually ...
4
votes
1answer
1k views

Indenting VHDL as other programming languages

When I write VHDL Vim uses a mix of tabs and spaces which aim to align columns beneath the last parenthesis. For example, Vim will produce something like Inst_IMem: IMem PORT MAP( ...
4
votes
2answers
1k views

Can I get vim to fold comments when using foldmethod=indent

When editing Python files at work I have to include 20+ lines of boilerplate legalese at the start of the file. "start of the file" is not that strict: I'm allowed to include the Python docstring, and ...
9
votes
6answers
6k views

How can I copy/paste new text without auto-indentation at every new line?

How I paste now: Right-click/Copy or simply highlight. Right-click/Paste or Middle Click or CTRL+SHFT+V Indents appear at increasing intervals: 0, 2, 4, 6, + Question at hand: From prior research, ...
6
votes
2answers
309 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 ...
4
votes
1answer
2k views

How to make auto-indent XML in vim?

I am thinking on a similar solution, which Eclipse also does: during the editing, the editor tries to always hold in a "well-indented" format of the edited textual data. Ideally, it would happen very ...
58
votes
6answers
50k 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. ...
4
votes
1answer
357 views

Why does Vim force programming indentation when in “gitcommit” filetype?

I found that when I am using Vim to compose git commit messages (which I have been doing for a very long time now) that there are occasionally some quirks. For example today I wrote a commit message ...

1
3 4 5
6
7