I've just switched from vim to neovim. The following vim config settings get the behaviour I want from indentation:
set tabstop=4
set shiftwidth=4
set softtabstop=4
set autoindent
set backspace=indent,eol,start
The relevant part here is the autoindent:
set autoindent
On each newline, this causes vim to match the indentation of the previous line:
def demo_autoindent():
a = 'This line was manually indented'
····
The declaration of a was manually indented one step, but the second line was auto-indented to the same level. Here I have represented the auto-indent with a series of · characters.
Neovim matches this behaviour. However, Neovim tries to be a bit clever with blocks, or in this case declaring dictionaries in python:
def example_neovim():
b = {
············
Note that Neovim has not auto-indented this line. If it had, it would have the same 4-space indent as the declaration of b. Instead, Neovim has added an extra two indents, bringing the total to 12-spaces.
Clearly what it intends to do is add one further indent:
def example_neovim_intention():
c = {
········
How do I configure Neovim to either:
- Match the behaviour of vim, just auto-indent to the same level.
- Add a single (rather than a double) extra indent when declaring e.g. a dict.