Questions tagged [indentation]

Prefixing lines with whitespace to aid in readability.

Filter by
Sorted by
Tagged with
2
votes
3answers
91 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
26 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
20 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
25 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
101 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
34 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
30 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
26 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
28 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
27 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
16 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
52 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
34 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
35 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
21 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
50 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
37 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
64 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
52 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
378 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
127 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
56 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
89 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
188 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
95 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
31 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
54 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
66 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
65 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
148 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
55 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 ...
4
votes
1answer
46 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
vote
1answer
93 views

Override indentation settings with autocmd

When editing Typescript neovim automatically sets indentexpr=GetTypescriptIndent(). I don't like the way it aligns to an open brace instead of inserting a (soft) tab or two, but it doesn't seem to be ...
1
vote
1answer
42 views

What setting causes my autoindent to add indent on a new line?

I have this go code snippet that I am working on in vim with vim-go enabled. | is where my cursor is at. // PlayerServer is a HTTP interface for player information type PlayerServer struct { ...
0
votes
2answers
58 views

Find and replace only between searched patterns

Editing large HTML file. Would like to do something like: :/<blockquote>/,/<\/blockquote>/s/^\(\s\s\+\)\(<[^>].\{-}>\)/\1 \2/g So basically just trying to indent all between ...
0
votes
1answer
31 views

How to have the cursor at the right indentation when editing PHP/HTML

When I'm working with HTML in a PHP file and I press enter while in INSERT mode, my cursor goes to the start of the next line instead of going at the right positive therefore I have to press tab to ...
1
vote
0answers
37 views

Where can I find good indentation file for lex filetype?

I checked and found only a syntax file for lex filetypes in /usr/share/nvim/runtime/syntax, but found no indent file in /usr/share/nvim/runtime/indent I want my lex files to be properly indented; one ...
2
votes
2answers
158 views

Format / Indent c++ as you type inside expressions

In visual studio, that code : for(int x=0;x<10;x++) {} becomes that code : for (int x = 0; x < 10; x++) { } as soon as you hit enter. I was wondering, is it possible, and if so, how can I ...
2
votes
1answer
484 views

Why does vim still auto-indent LaTeX after I set noai noci nosi?

I want to disable autoindent and smartindent for LaTeX so I did :set noai noci nosi When I open a brand new mwe.tex, filetype=plaintex and there is no auto indent magic. When I then enter some code,...
1
vote
2answers
100 views

How to move a cursor to the last line with auto indent?

Assume autoindent is set, and you have the buffer below. Note the cursor is represented as I. for i in range(1, 6): print(i)I When you hit Enter key, you get this. for i in range(1, 6): ...
1
vote
0answers
25 views

How to get the right indentation and new line when adding a new line between brackets? [duplicate]

So I am curious about one thing: when I am between two brackets ({) in vim (or nvim), and I press Enter I go from this (where the pipe sign is the cursor): getUsers(){|} to this: getUsers(){ |} ...
2
votes
3answers
935 views

How to indent or unindent lines in a block of text?

I use two spaces in my indentation of codes. What are the possible ways to indent or unindent a block of code?

1
2 3 4 5 6