Questions tagged [indentation]

Prefixing lines with whitespace to aid in readability.

Filter by
Sorted by
Tagged with
0
votes
0answers
8 views

Indent line in xml after omni-completion

When editing xml, lines are indented when pressing (among others) <, > or <CR> according to the indentkeys setting. For example: <tag> </tag| If the cursor is on | and I ...
0
votes
1answer
17 views

Understanding interaction between visual, autoindent, and paste option

Let's start form this faulty C++ source file #include <vector> int main() { std::vector<std::vector<int>> v{ 1,2}, 9,3}, 4,2} }; } which ...
1
vote
1answer
28 views

Understanding indenting rules for C++ files

Why is the following C++ source file indented like this, #include <vector> int main() { std::vector<std::vector<int>> v{ {1,2}, {1,1}, {1,2} };...
0
votes
1answer
29 views

Vim indentation different on linux and macOS

I'm using vim to write in C for college. My .c files need to abide to specific formatting rules. While I'm writing my files on Linux, the .c files will be evaluated on macOS. I noticed that any tabs ...
0
votes
0answers
33 views

`filetype plugin indent on` with `filetype=html` over-indents <script>

Since my last system update (I think), I have noticed this very annoying behavior. # vim foo.html # I go to insert mode, I type (no whitespace except newlines) <html> <head> ...
0
votes
1answer
26 views

Unwanted cascading indentation [duplicate]

I am struggling to regain control of indentation for certain filetypes, particularly when pasting code. I end up with what I call "cascading indentation" which is nearly unreadable. I've run ...
0
votes
0answers
18 views

How to write a function to set nobreakindent when using the Pencil plugin?

I'm trying to get the Pencil plugin to run with the noautoindent and nobreakindent settings. This is what I've tried in my init.vim: + 201 function! s:pencil_enter() + 202 set nobreakindent + 203 ...
2
votes
0answers
27 views

Reformatting a tab in vim [closed]

I am new to vim, and I'm facing an interesting problem. I need to reformat a file so that the indentation is consistent. How do I do this?
1
vote
1answer
97 views

Vim doesn't use default indenting for markdown

My default indent width settings (4 spaces) are not used for markdown files. Whenever I open a markdown file it is indented using 2 spaces. Here are my default indent width settings. In my .vim/vimrc ...
2
votes
1answer
30 views

Automatically indent at the right level when moving to a completely empty line

I have this binding in my .vimrc to trick autointent into actually populating the next line with real characters, so that if I hit enter, leave the line, and click back to it, I can already be at the ...
2
votes
3answers
109 views

How to change indentation in “case” with curly braces? [duplicate]

The default is this: switch(x) { case a: { y(); } } But I need this: switch(x) { case a: { y(); } } With :set cindent and :set cino={-s this is ...
0
votes
1answer
144 views

Fixing tab and space inconsistency

I used < in visual model to do a shift+tab reverse for a code inside loop after I removed the try/except phrase. Now, I get an error: $ python clean_captions.py File "clean_captions.py"...
2
votes
1answer
25 views

How can I have jinja2 indentation and syntax when keeping HTML filetype?

I have emmet installed and some more plugins that are usable on html filetypes, I would like to have syntax highlighting and have indentation for jinja2 while keeping the filetype HTML so my HTML ...
1
vote
1answer
40 views

incorrect auto-indent behavior

In some very specific scenarios, the auto indenter has almost unexplainable behavior that is very annoying. Example with haskell MultiWayIf syntax (cursor is at the "!"): test | test ...
2
votes
1answer
26 views

bad comment behavior in cmake files

When I'm editing a cmake file in (neo)vim I'm getting bad behavior block inserting comment characters. Given this section of text install_license_file( PACKAGE tomcrypt TARGET ...
3
votes
3answers
107 views

How can I indent selected lines in Visual mode by space granularity instead of TABs?

How can I indent lines selected in Visual mode using space granularity instead of than TABs (i.e. < or >)? Sometimes when coding Python, I need to indent lines to a level that is not a TAB ...
1
vote
1answer
36 views

How to tell vim to ignore extern “C” brakets while indenting?

I have the following in my .vimrc to indent the whole file: nnoremap cu gg=G`` I have a problem using this in source files that have #ifdef __cplusplus extern "C" { #endif // code #ifdef ...
0
votes
1answer
34 views

Is it possible to configure Vim to indent line continuation differently from indented blocks?

Here is an example of line continuation: ThisIsASuperLongClassNameWithALotOfExtraCharacters thisIsALongVariableName = ThisIsAModeratelyLongSuperClass.longFunctionCall( ...
0
votes
0answers
17 views

Is there a way to automatically reindent a selection while preserving relative indentation?

Suppose that I have a file that looks like this: aaa bbb ccc If I select lines 2 and 3 in visual mode and reindent with =, the result is everything in the same line: aaa bbb ccc Is there a way ...
1
vote
0answers
12 views

Get comments LINED UP in 65c816 asm syntax [duplicate]

I've been writing some 65c816 assembly lately. They have some interesting commenting conventions that I was hoping VIM could help me with. LDA $E7 ; You see, they BEQ IfZero ...
0
votes
1answer
11 views

vim plugin changes rust files to use a ts of 4 rather than 2

Let's say I have a simple file, echo -n "\tTABBED ONCE" > foo.rs And then I have in my .vimrc the following, set ts=2 call plug#begin('~/.vim/plugged') call plug#end() How come I open that file ...
1
vote
1answer
30 views

maintain alignment of text after folding

When a block of text is folded in vim, the first line of folded text is displayed in the foldline at a constant offset from the left edge of the window. Can the offset of that text be instead set to ...
0
votes
1answer
31 views

Using linebreak and other commands to customize vim indentation

I am using vim, by default I have not set the linebreak option in vim.So the following code: aug =ImageDataGenerator(width_shift_range=0.1,height_shift_range=0.1,horizontal_flip=True,fill_mode="...
1
vote
1answer
33 views

Vim autoindent and xml self-closing

(previously posted on https://stackoverflow.com/q/62000643/3206025 before I get that there is a Vi's SE) Here my vimrc filetype plugin indent on set autoindent set tabstop=2 set shiftwidth=2 set ...
0
votes
0answers
19 views

How to prevent Smart-Tabs plugin from overriding youcompleteme tab completion

I've been looking for a solution to "tabs for indentation, spaces for alignment" and found that the Smart-tabs plugin does exactly what I want. However, when this plugin is active, it breaks the tab ...
1
vote
1answer
53 views

Reformat code: breaking lines and aligning on a character

I am writing code in R, specifically using the Tidyverse packages. There is extensive use of the pipe %>% to chain functions together. The lines become long, so it is recommended to break them up ...
1
vote
1answer
42 views

Vim plugin for different languages in one webfile

I have the annoying issue that I have a .php file with HTML, CSS, Javascript and PHP. I use Vim. But the autoindent is always messed up and only works for one language in the whole file. Is there a ...
0
votes
2answers
36 views

How to make the indentation more smart

I'm using vim to code and I set autoindent in my ~/.vimrc. Now, if I code as below: if (a == 1) {| // the cursor is here and I type ENTER } After typing the ENTER, the code becomes as below: ...
1
vote
0answers
22 views

Autoindentation in .tex files

I use Vim to write Latex code and I would like to have autoindent when adding environments. I am aware of the smartindent capabilities that can be toggle on and off by inspecting the $VIMRUNTIME/...
2
votes
1answer
51 views

What option controls how much space is added after a new line?

When I set tw vim will auto wrap lines at tw. When breaking that line vim usually places some spaces to keep the indentation of the previous line. Example foo bar<suppose that a wrap happens ...
0
votes
1answer
46 views

Vim ignores `filetype indent off`

I don't have a personal vimrc. I use /etc/vimrc. The last 2 lines are: let testvar=999 filetype indent off I confirmed execution at the vim prompt using :echo testver, which displays 999. I tried ...
1
vote
3answers
73 views

Create a mapping for a “smart” Home key

With other text editors, if you press Home, it first takes you to the indent, then all the way to the left. Is this possible with Vim?
1
vote
2answers
81 views

Pasting text on Vim inside tmux breaks indentation

Ubuntu: 18.04 bionic tmux: version 2.6 VIM: Vi IMproved 8.0 (2016 Sep 12, compiled Jun 06 2019 ) Included patches: 1-1453 Modified by pkg-vim-maintainers@lists.alioth.debian.org Compiled by pkg-vim-...
1
vote
2answers
524 views

Auto-indent after carriage return after line containing open curly brace

I recently upgraded my Cygwin from a 2015 installation (5 years ago) to the current "2020" version. Gvim now automatically indents by shiftwidth columns when I press return after a curly brace { on a ...
0
votes
2answers
39 views

How to delete entry from indented argument from list?

Let's say with the cursor I'm on b in def f(a=1, b=2, c=3, e=4 ) and we want to delete the whole argument including the line break, so that we get def f(a=1, c=3, ...
2
votes
1answer
51 views

What is necessary to properly indent shell scripts with gg=G?

I was editing a small configure script and noticed that vim's indentation of the file was not working properly. A sample of the original source follows: while getopts 'dgSsx' opt; do case $opt ...
1
vote
2answers
181 views

Pressing Enter removes indentation

If I have a file a.js like this: let a1 = [ ]; and I press Enter at the end of the first line, a Tab is inserted. I do not want this, so I added a setting: filetype indent off but then if I have ...
2
votes
1answer
72 views

Keeping indent (like breakindent) when using hard wrap with textwidth

I know the breakindent option works with linebreak to preserve indent on wrapped lines. However, when I want to hard wrap lines (using the textwidth option so <EOL> is inserted when a line ...
0
votes
1answer
45 views

What vim setting determines the amount of indentation change by pressing > or < (greater than or less than)? [duplicate]

For me the > and < are set to 8 spaces. I would like them to be set to 4 spaces. What setting corresponds to this?
1
vote
1answer
96 views

How to indent text between specific line numbers in vim?

Let's say I want to indent everything between lines 40 and 60 (both lines included). One way of doing this is to go to line 40 and indent 21 lines: :40 21>> I am slightly bothered by having to ...
1
vote
1answer
53 views

Why does my line indent?

Please see line 20 and 21: My question is about how vim decides to auto-indent line 21, and how to adjust that behaviour. When I took this screenshot I had formatoptions=qrn1a set, however I believe ...
4
votes
1answer
219 views

Vim highlighting random indentations

As seen from the image, Vim decides to highlight those indentations for no reason. I've tried :noh and :set nolist (:set list seems to make it go away, but I don't want indentation marks) from a ...
1
vote
1answer
147 views

How to set custom shortcut in vim?

I want to make use of Shift+Tab to left-shift (unindent) a block of text, instead of Ctrl+d. How to do it?
1
vote
1answer
32 views

Paste into a new line and preserve indentation

I want a mapping that does it. Apparently, it is not that simple. Because first, it might decide to keep it commented when I press o. And it behaves differently if it was copied by yy, insists adding ...
2
votes
2answers
55 views

Fix indentation in a file while keeping cursor on the same line

I'd like to use vim's builtin indent fix feature on an entire file. I have looked up answers, but all I found were suggestions to type gg=G, the only problem being that it brings your cursor to the ...
0
votes
1answer
68 views

Keep indentation after multiple newlines

I've got a problem where in insert mode, if I type something like { that will cause indentation, then press enter twice, then match that bracket (such that there is a line in between the opening and ...
0
votes
1answer
71 views

insert new bullet point in autoindent mode

with autoindent mode on, when writing a short bullet point on restructuredtext file: - item one ~ Then I press Enter, and I get: - item one ~ but I whould like to quickly by here: - ...
1
vote
0answers
178 views

Smart and auto indent not indenting as expected for JSX

I'm trying to figure out how to get vim to correctly indent the next line in a JSX block. Currently when I press enter, the cursor goes slightly behind where it should be. In the example below, my ...
1
vote
1answer
60 views

Why is the commit message inside parentheses wrapped so strangely?

I sometimes need to do some remarks in parentheses in my commit message's detailed part. But when the parenthesized text comes to the rightmost column and is line-broken, the next line for some reason ...
5
votes
1answer
54 views

gq in visual mode indents just first two lines of enumeration

Some markdown as an example. I select the following paragraph in visual mode and press gq. The result is: - Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor ...

1
2 3 4 5
7