Questions tagged [indentation]

Prefixing lines with whitespace to aid in readability.

Filter by
Sorted by
Tagged with
0
votes
1answer
270 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
263 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
613 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
850 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
274 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
543 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
179 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 ...
11
votes
1answer
5k views

Why is “set noexpandtab” in my ~/.vimrc ignored when I open a file? [duplicate]

I'm using Mac OS X 10.12 and I have set noexpandtab in my ~/.vimrc There are 2 different behaviors : $ vim file.py If run Vim (8.0) to open one file and type :set expandtab?, it says expandtab $ vim ...
1
vote
0answers
103 views

Files with tabs are length 8 even with set tabstop=4 in vimrc [duplicate]

I have most of the usual tab commands in ~/.vimrc: set tabstop=4 set softtabstop=4 set shiftwidth=4 set expandtab set breakindent set autoindent set smartindent. There are no problems when I open a ...
1
vote
1answer
357 views

Extra indent in Vi/Vim Tcl code block indentation

I am using the gg=G, =ap etc. paradigms to reformat some code. This code is in tcl: proc something { foo bar } { set foo [yadda yadda] set foo [yadda yadda] set foo [yadda yadda] } When I try adjust ...
0
votes
0answers
117 views

indentation different on different computers

If I indent the following script with gg=G: #!/usr/bin/env bash while true; do case "${1}" in -h) usage; exit 0;; -b) branch="${2}"; shift 2;; -t) build="${2}"; shift 2;; ...
0
votes
1answer
352 views

Strange behaviour when inserting tabs

I thought I knew how Vim handles indentation but apparently I was wrong. When I type at the beginning of a line, everything seems to work as expected. However when I type somewhere inside a line, ...
0
votes
1answer
701 views

Temporarily disabling Smart-Tabs

I'm using https://github.com/vim-scripts/Smart-Tabs/blob/master/plugin/ctab.vim through Vundle. How can I temporarily disable it (preferably more readily than by commenting out the bundle and ...
7
votes
2answers
410 views

How can I shift only inner contents of HTML element?

How can I quickly shift only inner contents of HTML tag X, when they are on separate lines to the opening and closing X tag? Example below: I want to shift only 2 lines with <p> tags when the ...
1
vote
1answer
9k 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 ?
0
votes
1answer
912 views

How to correctly indent when beginning a new line below the cursor ('o')? [duplicate]

Screenshots My problem I am working on a js file, using eslint as my linter with the ale plugin, configured using the airbnb standard which mandates 2 space indentation. When I open a new line by ...
0
votes
1answer
389 views

Ruby indentation: align multiline method chains on the leading dot?

Vim indents Ruby multiline method-chains like: object.read .write .rithmetic I'd like to make it align the dots instead: object.read .write .rithmetic I haven't been able to find a ...
4
votes
2answers
197 views

Get same indentation behavior as opening a new line on an empty line

Whenever I open a line using o or O, the cursor starts at the correct indentation (I'm not sure if vim uses syntax hints for this or just mimics the position of first character of the neighboring ...
3
votes
1answer
457 views

Wrong indentation for fortran forall

I'm using Neovim to edit Fortran 90 files and if I type the one-liner: forall(i=1:10) b(i) = i Neovim will always assume that it has a forall block and indent the following lines (til the end of the ...
1
vote
0answers
50 views

How to ensure smarter indentation after multiline function header?

I am using Javascript with typescript if it matters (I don't think it does for this question for reasons that I will explain later) and I have the following code: veryLongFunctionName(arg1: type, ...
5
votes
1answer
3k views

Expand <TAB> into 2 spaces when and only when editing HTML

My current configuration makes vim automatically expand TAB to 4 spaces for me: " Define tab as 4 spaces " Taken from http://stackoverflow.com/questions/1878974/redefine-tab-as-4-spaces set tabstop=4 ...
0
votes
1answer
182 views

Run command on all .JS files in a directory recursively?

Someone at my workplace committed non-indented JavaScript I have the VIM plugin autoformat installed and want to run :Autoformat on all .js files in my project directory, how would one do this?
6
votes
2answers
2k views

How do I jump to the next line with the same indent level?

I have a space formatted (yaml) file like the following: en: templates: template: "VERYLONGTEXTHEREWITHHUNDREDSOFLINES" destination: "I want to jump here" other: stuff ...
1
vote
1answer
356 views

See what indenting style is being used in Vim

I've recently started up a project using Typescript. When I start up Vim, open up a .tsx file and open a new line, it fails to indent: I then open up a regular javascript file (.js), and return to my ...
1
vote
1answer
499 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 ...
2
votes
1answer
120 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 ...
3
votes
2answers
2k views

Can vimwiki be made to treat list indentation the way vim-notes does?

I've looked through the vimwiki documentation and a few questions here on SO, but don't see how I can manage this. In vim-notes, hitting TAB within a list indents the entire list item. In vimwiki, ...
6
votes
1answer
259 views

Indent Lines Up Without Moving

I frequently use the >8j and >8k commands to indent several lines at once. Using j, the lines are indented and my cursor stays at the first line. When I use k, the lines are indented, but my ...
1
vote
1answer
855 views

Python: Strange auto indent behavior after function call

Can anyone explain to me why when writing python code, vim is auto indenting when entering carriage return after function call ie. f.write(name, r) Before writing(:w) file import bs4 as bs import ...
3
votes
1answer
400 views

How do I control how vim indents ruby blocks?

When I start a ruby block in the middle of a line, the next line is indented deeper than I'd like. It's indented from the start of the block, not the start of the line. Example: some_variable_name =...
3
votes
2answers
637 views

Lag from filetype plugin indent on

I'm getting lag in vim when navigating relatively small text files if filetype plugin indent on is uncommented in my vimrc file. My full vimrc file is pasted below. Any help on how I can get it ...
1
vote
1answer
130 views

Indenting when using ()

When I use braces (, the indenting is screwed up. Filetype is not set (but it's the same if I set it to e.g. txt). Here's what I type: foo<CR>bar<CR>foo (<CR>bar Here's how it ...
2
votes
1answer
238 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
870 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, ...
0
votes
1answer
196 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 ...
0
votes
0answers
731 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
772 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/...
2
votes
1answer
822 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 ...
5
votes
1answer
2k 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 ...
2
votes
1answer
383 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 ...
6
votes
1answer
545 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 ...
4
votes
1answer
321 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 - ...
6
votes
1answer
850 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
660 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
191 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, ...
5
votes
2answers
5k 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 ...
2
votes
1answer
232 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
149 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 ...
4
votes
1answer
3k 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: ...
4
votes
1answer
1k 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 ...

1 2 3
4
5
7