首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何正确设置Vim自动缩进来编辑Python文件?

如何正确设置Vim自动缩进来编辑Python文件?
EN

Stack Overflow用户
提问于 2008-09-15 17:48:23
回答 7查看 118.2K关注 0票数 89

我在设置Vim (7.1.xxx)来编辑Python文件(*.py)时遇到了问题。缩进似乎被破坏了(最好4个空格)。我遵循了我在谷歌上找到的一些教程。仍然没有效果:/请帮助。

EN

回答 7

Stack Overflow用户

发布于 2008-09-15 17:53:33

我在我的macbook上使用以下代码:

" configure expanding of tabs for various file types
au BufRead,BufNewFile *.py set expandtab
au BufRead,BufNewFile *.c set expandtab
au BufRead,BufNewFile *.h set expandtab
au BufRead,BufNewFile Makefile* set noexpandtab

" --------------------------------------------------------------------------------
" configure editor with tabs and nice stuff...
" --------------------------------------------------------------------------------
set expandtab           " enter spaces when tab is pressed
set textwidth=120       " break lines when line length increases
set tabstop=4           " use 4 spaces to represent tab
set softtabstop=4
set shiftwidth=4        " number of spaces to use for auto indent
set autoindent          " copy indent from current line when starting a new line

" make backspaces more powerfull
set backspace=indent,eol,start

set ruler                           " show line and column number
syntax on               " syntax highlighting
set showcmd             " show (partial) command in status line

(编辑为仅显示与缩进/制表符相关的内容)

票数 79
EN

Stack Overflow用户

发布于 2012-08-06 23:01:33

我使用:

$ cat ~/.vimrc
syntax on
set showmatch
set ts=4
set sts=4
set sw=4
set autoindent
set smartindent
set smarttab
set expandtab
set number

但我要试试达伦的作品

票数 15
EN

Stack Overflow用户

发布于 2017-06-03 10:05:02

一种更简单的选择:只需在/etc/vim/vimrc文件中取消注释配置的以下部分(最初已注释掉):

    if has("autocmd")
      filetype plugin indent on
    endif
票数 12
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65076

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档