Questions tagged [indentation]
For questions about prefixing lines with whitespace to aid in readability.
370
questions
0
votes
0
answers
22
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 ) ...
2
votes
1
answer
67
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 ...
2
votes
1
answer
65
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 ...
1
vote
1
answer
75
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/...
0
votes
0
answers
23
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 ...
1
vote
0
answers
27
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 ...
1
vote
1
answer
200
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 ...
2
votes
1
answer
555
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 ...
1
vote
0
answers
32
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=...
3
votes
1
answer
141
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
...
1
vote
1
answer
166
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
...
1
vote
1
answer
62
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 / ...
0
votes
1
answer
21
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 ...
1
vote
0
answers
42
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 ...
1
vote
1
answer
48
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 ...
0
votes
0
answers
24
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 ...
1
vote
1
answer
31
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 ...
1
vote
1
answer
133
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 ......
1
vote
1
answer
82
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 ...
0
votes
0
answers
201
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
...
0
votes
0
answers
63
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 ...
1
vote
2
answers
164
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 = [
'...
0
votes
1
answer
22
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 ...
0
votes
2
answers
894
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>...
0
votes
1
answer
43
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 ...
1
vote
0
answers
30
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 ...
0
votes
1
answer
64
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 ...
0
votes
0
answers
139
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 ...
2
votes
0
answers
213
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 ...
0
votes
1
answer
32
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 ...
3
votes
2
answers
276
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://...
0
votes
1
answer
636
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 ...
3
votes
1
answer
75
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....
0
votes
1
answer
199
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 = ...
2
votes
1
answer
120
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).
...
2
votes
1
answer
378
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
...
1
vote
0
answers
29
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 ...
3
votes
1
answer
144
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 ...
0
votes
0
answers
193
views
Empty line indentation for Python
Whenever I press o or O, VIM starts the line with the desired indentation. At work, people have decided that they want empty lines to be indented as if it contained code, such that code can be copied ...
0
votes
1
answer
141
views
vimtex: configure to indent '[ ... ]' and '\[ ... \]' blocks
When setting indentation using vimtex, I meet some problem.
I set the option g:vimtex_indent_delims to indent [...] blocks.
let g:vimtex_indent_delims = {
\ 'open' : ['{','(','['],
\ '...
1
vote
1
answer
139
views
vimtex: fully indent a '{ ... }' block
Concerning indent in vimtex, it has some settings controlling indenting of delimiters, the option seems to be g:vimtex_indent_delims. However, I would like to not only indent the text between opening ...
2
votes
4
answers
443
views
How to move cursor up to nearest upward smaller level of indentation
Imagine my cursor is where the ^ is in this document:
{
"first": [
{
"second": {
"third": [
"fourth"
]
}
},
{...
1
vote
1
answer
389
views
`:call append!` -- how vim insert line (append or setline) while respecting indentation
I want to put a string function output in my vim when press xx. My current working example is:
nnoremap <silent> xx :call append('.', 'string_output')<CR>
However, this put a line without ...
7
votes
4
answers
796
views
Vim plugin where the first lines in the editor show the first line(s) with less indendation that are not visible
I would like to either find or write a plugin that does the following:
Assume I have this python code:
def foo(a,b,c):
# comment
[100 lines that do stuff]
for i in range(N):
[100 ...
0
votes
1
answer
40
views
Vim treats paths with wildcards( /*) as C-style block comments and applies weird indentation
Vim 8.1 from Ubuntu 20.04 thinks /* in include /etc/nginx/conf.d/*.conf; is a start of a C-style block comment and gives wrong indentation in default nginx.conf file when using '=':
http {
...
1
vote
0
answers
229
views
vim doesnt recognize html in string in filetype php. same thing with php code in filetype html
Ive had no luck solving these issues for quite a while now.
Problem1
When writing HTML inside a string in a file with filetype=php, the HTML is not recognized (i.e., it has no highlighting or indent).
...
2
votes
2
answers
135
views
How to remove this weird default indentation?
If I do gg=G on a file with the following text
- 2018-2019 ICPC Northwestern European Regional Programming Contest (NWERC 2018)
- 2020 ICPC Universidad Nacional de Colombia Programming Contest
- ...
0
votes
0
answers
112
views
How can i get visualize line indent every time i use tab or go to new line
I set
set listchars=tab:\│\
set list
to my vimrc and it shows like below
But when I go to another file it doesn't have a vertical line indent. It just affected 1 file, I have no idea about this. ...
4
votes
1
answer
8k
views
How does smarttab actually works?
Yes, I'm aware of what :h smarttab says, but I still cannot figure it out.
" My vimrc
set backspace=indent,eol,start
set tabstop=8 " I always keep this 8
set shiftwidth=4
set softtabstop=-1 &...
1
vote
1
answer
44
views
How to totally close all the auto indent
In my case, I was writing a tex file. After Closing some auto indent settings
set noai noci nosi
filetype indent off
filetype plugin indent off
But vim still gave me 2 tab indent when I type { or [ ...