Skip to main content

Questions tagged [indentation]

For questions about prefixing lines with whitespace to aid in readability.

Filter by
Sorted by
Tagged with
0 votes
1 answer
61 views

indent python files with only 2 chars on linux

I have this project where python files are indented with 2 chars, not 4. On my mac, I use macvim (VIM - Vi IMproved 9.1 (2024 Jan 02, compilé Jan 4 2024 03:08:50)). When I edit a file like this: #!/...
exore's user avatar
  • 101
1 vote
1 answer
24 views

Can I change indentation when type and name are on different lines?

When I write: { my_type my_name; } in C/C++, putting a new line between the type and name is formatted by the = action as follows: { my_type my_name; } I would prefer if it was ...
thruse's user avatar
  • 25
0 votes
0 answers
31 views

Force vim to use 4 spaces in reStructuredText

I am trying to write some rst files for documenting a Python package, but it is a nightmare to work on it. When I press Enter I get 3 spaces: This is text text after Enter When I press Tab after ...
ado sar's user avatar
  • 101
0 votes
0 answers
13 views

How can I put a bullet point above or below the current line and have the same indent level automatically? [duplicate]

Let's say I have these bullet points - First Line - Second Line - Third Line On the second line I do dd, move down to the third line and do p, the second line gets pasted below with no indent, ...
Oneechan69's user avatar
0 votes
1 answer
62 views

Why are my Markdown files being auto-formatted with extra spaces?

I edited a markdown file as a.md # Title ## Sub Title - a - b - c After saving the file, it became: # Title ## Sub Title - a - b - c How do I fix it? It seems that Prettier is ...
Alpin Cleopatra's user avatar
0 votes
1 answer
47 views

automatically indenting code in two column based style

What kind of plugin, cindent options, or alike, can I use to indent the code in two column, the first column indented based on block-depth, and the second based on the column of the assignators of the ...
ax ax's user avatar
  • 35
0 votes
1 answer
17 views

Setting guard variables does not prevent default ftplugin/syntax/indent files from running

I want to prevent the default ftplugin/syntax/indent files from running for tex files. I have a tex.vim in the $XDG_CONFIG_HOME/nvim/ftplugin directory, i confirmed it runs before the default ftplugin/...
CoelinG's user avatar
0 votes
1 answer
38 views

Is there a setting for maximum indent level?

After setting manual fold by indent with set foldmethod=indent, I found that seems the max indent level is around 20, i.e. more than 20 levels will collapse together. May I know if there is a setting ...
athos's user avatar
  • 207
0 votes
1 answer
52 views

Preventing cursor from indenting after a previously indented line

I'm using neovim and a init.lua file. In what follows X will indicate the cursor: for i in range(1,5): print(iX Then I press o: for i in range(1,5): print(i) X Then I press backspace: ...
robertspierre's user avatar
-3 votes
1 answer
51 views

Why four spaces turn into two when copying lines from gVim into LibreOffice? [closed]

I want to paste some codes in gVim: You see that there are 4 blank spaces at the beginning of line 2 till line 4. Issue %y+ in gVim, copy all the lines into register, then paste it in LibreOffice: ...
showkey's user avatar
  • 1,150
1 vote
1 answer
92 views

How to have different indentation styles depending on the file?

The way the code needs to be indented depends on the filetype. How can I configure Vim to use the correct value of tabstop, shiftwidth and expandtab depending on the file?
Vivian De Smedt's user avatar
1 vote
3 answers
2k views

Why is indentation on Github different from indentation in my Neovim?

After committing I realised that indents on GitHub show differently from what I see in Neovim. I also noticed that all formatting (including indentation) is reset when an error occurs when loading the ...
Glub-tubus Wepple's user avatar
0 votes
0 answers
31 views

Strange auto indent in Javascript in HTML

When writing Javascript in HTML, vim insists on autoindenting like this: if( dur.match(/:/) ) { let xs = dur.split(":") if( xs.length > 3 ) ...
John Allsup's user avatar
2 votes
1 answer
89 views

Wrong indentation in brackets

How can I change the automatic indentation inside brackets? Without any configuration, {vim,nvim} does the following: test = [| # Press enter test = [ | # Cursor ends up here, at the same ...
Elevator9253's user avatar
2 votes
1 answer
158 views

How do I tell (*Neovim*) that `.ipynb` files have 1 space indents, so indent guides are correctly shown?

I'm using the Indent Blankline plugin to show indent guides. My Jupyter Notebook/.ipynb files have 1 space indents. Vim identifies them as JSON files. One way to tell Neovim that Jupyter Notebook ...
simonzack's user avatar
  • 125
1 vote
1 answer
90 views

Indentkeys Tab behavior

I want to have something similar to EMACS tab behavior (described in help indentkeys-format) but I still want to be able to input more tabs if I want. I thought that adding !0<Tab> to indentkeys/...
gruvw's user avatar
  • 63
0 votes
0 answers
45 views

Why does <esc> on empty, indented line, jump to beginning?

I'm trying to do something very simple, enter normal mode and ALWAYS be able to somehow put the normal mode cursor where it was in insert mode, whether through a mark, or otherwise. I'm doing this ...
Tallboy's user avatar
  • 177
1 vote
0 answers
34 views

How to allow manual folds with indent folds defined?

I want to be allowed to create any folds at all, but I also want Vim to generate all the indent-based folds for me so that I can still use indent-based folding. Is there some way to mix indent-based ...
Captain_Obvious's user avatar
1 vote
1 answer
532 views

How to fix indentation for *.nix files?

How can I tell Neovim not to ignore characters after // as well as treat (space) in lists as separator when it comes to indentation? Closing }; below users.root should be two characters to the ...
Martin Braun's user avatar
3 votes
1 answer
3k views

How can I make (Neo)Vim wrap lines in respect to indentation?

Currently, indented lines will wrap all the way to the left of the text area. This is what they look like: This is a long line of text that is indented wi th tabs. In order for it to properly fit ...
natalie's user avatar
  • 33
1 vote
0 answers
40 views

What could be causing this indent behavior?

In Typescript files, when I create enums I have a comma at the end of each line. enum thing { first = 'first', | // <--- when I press enter the cursor goes here } When I :set shiftwidth=...
Vinn's user avatar
  • 781
4 votes
1 answer
264 views

Trouble in overriding `indentexpr` in neovim

Say I do not quite like the shipped Lua indentexpr (GetLuaIndent(), defined in $VIMRUNTIME/indent/lua.vim). With vim, I can disable or change it using this minimal configuration: ~ % cat .vimrc ...
Futarimiti's user avatar
4 votes
1 answer
305 views

How to turn off auto indenting while editing a LaTeX file?

I edit a LaTeX file, and for some commands Vim does auto indenting. I would like to switch it off. Consulting: https://www.serverwatch.com/guides/automatic-indenting-vim/ I tried: :filetype indent off ...
Gergely's user avatar
  • 293
1 vote
1 answer
71 views

change behaviour of > / < and >> / << to insert / remove only leading tabs

i want > / < and >> / << to simply insert and remove tab characters at the beginning of the line. variant: i would even prefer to have> / < and >>/ << insert / ...
windfish's user avatar
  • 123
0 votes
1 answer
35 views

Manually indenting lines with tabs

Lines can be indented with tab characters. And it is quite obvious the there are better ways to do that than manually adding a tab character to the beginning of each line. But how to discover these ...
Volker Siegel's user avatar
1 vote
0 answers
44 views

Expand all non-leading tabs but keep leading tabs [duplicate]

I want to use tabs for indentation and spaces for alignment in the following way: keep tab characters (like noexpandtab) for all leading tabs of a file, but expand tabs (like expandtab) that occur ...
windfish's user avatar
  • 123
1 vote
1 answer
134 views

What's the Vim option to make indentation matches source file?

I just started at a new company where apparently there is no standardization on tab/space setting at all. Everything goes. That culture is not going to change. What I want to do is make Vim matches ...
vim is da best's user avatar
0 votes
0 answers
31 views

Indenting C with brace macros

I use a bunch of weird C macros which basically should behave like braces as far as formatting is concerned. My equalprg is empty, so I'm using vim's indenting function for = formatting. Is there any ...
Petr Skocik's user avatar
1 vote
1 answer
34 views

move (motion or visual selection) to own line and indent

Suppose I have the following text \[ X = (a, b) \] I want to easily convert it to the following, including indentation: \[ X = ( a, b ) \] Suppose my cursor is on a. How can I do ...
japreiss's user avatar
  • 151
1 vote
1 answer
250 views

How to stop Vim from indent template in C/C++?

I have piece of sample code (copied from stack overflow) //some lines of code template <typename ... Args> std::string string_format ( const std::string& format, Args ......
Rekkhan's user avatar
  • 43
1 vote
1 answer
109 views

Multiple "1 line >ed" messages

When I perform multiple shift :> operations, vim shows me a notification for each line that's shifted. Is there a way to avoid these multiple notifications? For example, I'm currently editing a ...
Keith Thompson's user avatar
0 votes
0 answers
322 views

block comments not automatically indented in Neovim

When inserting a block comment in a (TypeScript) buffer in Neovim, the line after the /**<Return> is not automatically indented. How can I achieve the expected behavior described below? Neovim ...
KIYZ's user avatar
  • 101
0 votes
0 answers
81 views

Vim doesn't keep keep the same indentation as the line above it only in one situation

fn main { scores.entry(team_1_name) .and_modify(|&mut team| { team.goals_scored += team_1_score; team.goals_conceded += team_2_score; }) } When I press ...
brianxk's user avatar
  • 21
2 votes
2 answers
252 views

How to get the right indent size in python lists?

In my vimrc I have filetype indent plugin on When I write python code, the indentation mostly looks good, but in lists it is too big: def fun(): return 'indent looks good' my_list = [ '...
Burrito's user avatar
  • 131
0 votes
1 answer
23 views

Place cursor on opening brace, press "=%", why does the closing brace get indented (in addition to desired indentation of lines between the braces)?

I am following along in the book Vi IMproved by Steve Oualline. In Chapter 7, "Commands for Programmers", there is a discussion about indentation and the = command. Here is what I wrote in ...
xoux's user avatar
  • 125
1 vote
2 answers
1k views

Neovim keep html tags indented in react/jsx files

When I edit a .html file I get this when pressing enter key: <div>|</div> <div> | </div> and while I edit a react file, the behavior is not what I was expecting: <div>...
user44767's user avatar
0 votes
1 answer
51 views

How do I override indent/html.vim's attribute indent behavior

Stated Purpose I'm trying to override Vim's HTML attribute indent behavior. This question is specific to ft=html. Vim has always inserted too many spaces when indenting HTML: <div> <div ...
amphetamachine's user avatar
1 vote
0 answers
35 views

Is there a way to map remap 0<C-d> in insert mode

I'm doing a plugin which modify how shift works and remap <C-d> in insert mode. Every thing works well but I have a problem with 0<C-d>. It is a built-in mapping which reset the ...
mb14's user avatar
  • 156
0 votes
1 answer
83 views

How do I determine the indentlevel to customize showbreak?

I want wrapped lines to look like this: some really long line that | ... reached the end of the | ... window. | const indented = () => { | // a really, really, | ... really ...
Aaron Parisi's user avatar
0 votes
0 answers
192 views

How to set background color of lines in IndentLine?

I'm trying to configure Yggdroot/indentLine to use the same background color as used in whatever color scheme I'm using, that is I'd like the gray parts to have the same color as the background. From ...
flawr's user avatar
  • 185
2 votes
0 answers
246 views

JavaScript HTML Template Literal Indenting

I have https://github.com/Quramy/vim-js-pretty-template installed to handle syntax highlighting for template strings marked with /*html*/ But indenting does not work correctly - I end up with ...
Aaron Parisi's user avatar
0 votes
1 answer
78 views

Autoindent uses tabs after paste mode

My .vimrc: :set tabstop=2 :set shiftwidth=2 :set ai :set expandtab My workflow: vi filename type space spacetextenter, cursor is now under 't', indented with 2 spaces. As expected. :set paste paste ...
psx's user avatar
  • 115
3 votes
2 answers
355 views

Make Vim _really_ work with both spaces and tabs

Here is what I use for indentation: set autoindent set breakindent set expandtab set smarttab set shiftround set shiftwidth=2 softtabstop=-1 " or maybe shiftwidth=2 softtabstop=8 " https://...
john c. j.'s user avatar
0 votes
1 answer
802 views

Indent changes when using CoC, how do I stop this?

I have set up my init.vim file to always use tabs as indentation by adding this to it: set tabstop=4 set shiftwidth=4 set noexpandtab Ever since I installed CoC to use Rust's language server, it ...
Katie And's user avatar
3 votes
1 answer
118 views

How to indent C function parameters like curly braces and not with cino-(

From :h cino-(, I see that we can only indent the parameters for the function calls with respect to the opening bracket. This is problematic for functions with long names or within multiple namespaces....
3N4N's user avatar
  • 5,824
0 votes
1 answer
273 views

Indentation is messed up when pasting code

I find that the default indentation support for pasting is lacking. For example , If I use ]p for the following(copied using V) : try: l=None if 1: df = ...
eyal karni's user avatar
  • 1,146
2 votes
2 answers
249 views

How can I make Tab insert tabs at the start of the line only, and spaces after text?

What I want to achieve I would like to setup vim such that tabs are inserted on lines until another character is inserted, after which, further tabulation results in spaces (similarly to expantab). ...
NRagot's user avatar
  • 23
2 votes
1 answer
436 views

Force convert spaces to tab in all file type [duplicate]

So today I'm having some problems with vim. I wanted to use tab when I press the tab key, and a tab is equal to 8 spaces. This is what I added to my /etc/vimrc file: :set noexpandtab :set tabstop=8 ...
Someone1611's user avatar
1 vote
0 answers
35 views

False indentation after line continuation in if-else clause for `sh` filetype

I have shell script file (filetype=sh) like if [ -f filename ]; then echo "file exit" | \ cat - else echo "file not exist" fi When I select the block and apply ...
auditory's user avatar
  • 170
3 votes
1 answer
200 views

Java Code Conventions: How to set up autoindent

As recommended by Oracle's Java Code Conventions, I try to avoid lines longer than 80 characters. For this it's of course often necessary to break lines, and the document contains some general ...
PunktPunktPunkt's user avatar

1
2 3 4 5
8