gpt4 book ai didi

python - Vim 双缩进 python 文件

转载 作者:太空狗 更新时间:2023-10-30 02:41:23 25 4
gpt4 key购买 nike

我得到以下行为。给定此 settings.py 片段,从第 33 行点击“o”

31# Application definition
32
33 INSTALLED_APPS = [
34 'rest_framework',

我明白了

31# Application definition
32
33 INSTALLED_APPS = [
34 |<-cursor is here, two indents, 8 spaces
35 'rest_framework',

我真正想要的是一个缩进,或者总共 4 个空格,与列表的其余部分保持一致。是什么赋予了?我正在使用以下 .vimrc,我主要从 here 中抄录了它.

set nocompatible              " required
filetype off " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'

" Add all your plugins here (note older versions of Vundle used Bundle instead of Plugin)

" Themes
Plugin 'altercation/vim-colors-solarized'
Plugin 'jnurmine/Zenburn'

" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required

if has('gui_running')
set background=dark
colorscheme solarized
else
colorscheme zenburn
endif

au BufNewFile,BufRead *.py set tabstop=4 shiftwidth=4 textwidth=79 expandtab autoindent fileformat=unix

set encoding=utf-8
set nu
let python_highlight_all=1
syntax on
set backspace=indent,eol,start

最佳答案

这是因为 Python 的默认 vim 缩进插件。它在第一行 [ 下方插入 2 shiftwidth

您可以在此处查看导致此行为的代码:https://github.com/vim/vim/blob/0b9e4d1224522791c0dbbd45742cbd688be823f3/runtime/indent/python.vim#L74

我建议您安装 vim-python-pep8-indent完全按照您的需要在括号内进行缩进的插件。

关于python - Vim 双缩进 python 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39553825/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com