Questions tagged [indentation]

Prefixing lines with whitespace to aid in readability.

Filter by
Sorted by
Tagged with
1
vote
2answers
462 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=...
7
votes
2answers
531 views

Shift left or right (with `noet`) without converting existing spaces to tabs

Foreword I'm using the "indent with tabs, align with spaces" ideology for indentation. This means that each line in a file can be prefixed with an arbitrary amount of tabs and spaces (as opposed to "...
0
votes
1answer
38 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 ...
0
votes
1answer
52 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?
1
vote
1answer
888 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. ...
2
votes
1answer
222 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 ...
21
votes
2answers
23k 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
1answer
146 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
674 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/...
5
votes
2answers
92 views

Can I make the indent commands take an additional count that doesn't affect the motion?

Let's say I'd like to indent the current line 4 times. (Not 4 spaces, 4 indent commands). As far as I can tell, the shortest way to do this is >>... (Indent once, repeat three times) This ...
5
votes
1answer
318 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
0
votes
1answer
507 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 ...
15
votes
3answers
11k views

How can I automatically indent on new lines?

I work on projects with varying levels of indentation. In many of these projects, because of how the files are typically structured, most lines are indented at least two levels (such as methods in ...
0
votes
1answer
288 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
550 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 ...
3
votes
2answers
217 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
113 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 ...
7
votes
6answers
5k 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, ...
1
vote
1answer
120 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 ...
1
vote
1answer
78 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
59 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 /^...
1
vote
2answers
182 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
447 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
613 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
237 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 ...
1
vote
0answers
138 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
vote
1answer
247 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 ...
4
votes
2answers
104 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 ...
6
votes
1answer
3k 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 $ ...
0
votes
1answer
137 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?
1
vote
0answers
60 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
287 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
98 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
461 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 ...
0
votes
1answer
269 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, ...
6
votes
2answers
328 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 ...
0
votes
1answer
319 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 ...
0
votes
1answer
450 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 ...
1
vote
0answers
45 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, ...
4
votes
1answer
2k 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 ...
3
votes
2answers
635 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
281 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 ...
40
votes
7answers
10k views

Re-indenting badly indented code

I like the smart-indent feature of Vim, it allows me to create well-indented code blocks. I regularly copy/paste code in to buffers, but that code is often poorly formatted. What would be ideal is ...
2
votes
1answer
105 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 ...
4
votes
3answers
383 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 ...
16
votes
3answers
808 views

How do you indent > < without leaving visual mode and losing your current selection?

I often have to manually indent, but when I enter a visual mode, select my lines to indent, and press < or >, I leave visual mode whether I want to or not. I would rather have it so I stay in ...
5
votes
1answer
195 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 cursor ...
1
vote
1answer
680 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
299 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 =...
1
vote
1answer
125 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 ...