0

I'm using the plugin auto-pairs to help auto close brackets.

In vim when defining dicts or lists it'll auto formatting like this

| is the cursor position

a_dict = {
        | # the indent is 8 spaces width, but I already set 4 spaces width indent in .vimrc
        }

a_lst = [
        |
        ]

a_lst_with_a_very_loooooooooooong_name = [
        |
        ]

but I want it formats the code like this

lst = [
    |
]

How can I do this?

  • I have the same issue. Tried other plugins, works fine with them but they all pale in comparison to auto-pairs. Did you manage to fix it? – Abhirath Mahipal Apr 28 '17 at 6:12
0

For Python indenting in vim, I use this plugin for pep8 indentation with Vundle. This plugin works with yours and gives you the functionality you want (at least on my machine)

Example:

lst = [
    |
]

abc = {
    |
}

You especially want the let g:pymode_indent = 0 line in your .vimrc for the pep8 plugin.

Someone who is skilled in vim programming might be able to modify your plugin to do what you need, but this solution might bring you another benefits if you use vim for Python programming.

To address your issue with 8 spaces as a tab - try having all

set tabstop=4
set shiftwidth=4
set expandtab
filetype indent on

in your .vimrc (this is what I have and it gives me 4 spaces indentation)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.