我遇到了麻烦,请设置VIM(7.1.xxx)来编辑python文件。 缩进似乎被破坏(最佳4个空格)。 我跟着我通过Google找到的一些教程。仍然没有效果:/ 请帮忙。如何正确设置VIM自动缩进以编辑Python文件 - * .py
58
A
回答
55
我用这对我的MacBook:
" configure expanding of tabs for various file types
au BufRead,BufNewFile *.py set expandtab
au BufRead,BufNewFile *.c set noexpandtab
au BufRead,BufNewFile *.h set noexpandtab
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
(编辑只显示缩进相关的东西/制表符)
3
确保您正在编辑VIM正确的配置文件。特别是如果您使用的是Windows,那么可以将文件命名为_vimrc而不是其他平台上的.vimrc。
在VIM型
,并查询到_vimrc您的路径/ .vimrc中与
:echo $HOME
:echo $VIM
文件确认您只使用一个文件。如果你想将你的配置分割成更小的块,你可以从你的_vimrc文件中获取其他文件。
:help source
1
更先进的蟒蛇编辑考虑安装simplefold VIM插件。它允许您使用正则表达式进行高级代码折叠。我用它来折叠我的类和方法定义,以便更快地编辑。
4
我使用的vimrc中除其他事项外蟒蛇回购:
http://svn.python.org/projects/python/trunk/Misc/Vim/vimrc
我还加
set softtabstop=4
10
我用:
$ 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
不过,但我要去尝试达人的条目
2
一个简单的选择:刚刚取消对配置的以下部分(这是最初注释掉)在/ etc/VIM/vimrc文件:
if has("autocmd")
filetype plugin indent on
endif
相关问题
- 1. 编辑Vim缩进文件
- 2. Vim自动缩进不正确
- 3. Vim双缩进python文件
- 4. vim/vi/linux:正确缩进html文件
- 5. 如何锁定python(.py)文件进行编辑?
- 6. vim正确缩进python片段
- 7. VIM自动缩进LaTeX文件不好
- 8. 如何用正确的自动完成编辑Python脚本?
- 9. Haskell和Vim:正确缩进
- 10. 使用vim编码时自动缩进不起作用python
- 11. VIM编辑器:如何在VIM中进行自动格式化?
- 12. Vim缩进(Python编程)
- 13. VIM自动缩进不能正常
- 14. vim关闭自动缩进自述文件和文本文件
- 15. 如何在Atom.io编辑器中设置自动缩进和格式样式
- 16. Vim自动缩进换行
- 17. 如何修复vim以正确缩进包含Python注释行的折叠?
- 18. Vim在编辑不同文件时混合了缩进样式
- 19. 如何正确设置Vim的makeprg(Windows)
- 20. 如何编辑和运行带有IDLE的python文件.py
- 21. 如何在VIM中正确设置拼写文件?
- 22. 如何使Eclipse HTML编辑器正确缩进所有标签?
- 23. 如何正确缩进python-docx?
- 24. 将.py文件转换为正确的Python编码3
- 25. Java文本编辑器自动完成和缩进逻辑
- 26. vim-r-plugin vim-py-plugin的Python插件
- 27. 如何显示Vim中用于编辑haml文件的缩进指南行
- 28. 更改Python的Spyder编辑器中的缩进设置
- 29. 如何以编程方式设置VIM文件类型?
- 30. Vim:如何将自动缩进(使用等号)设置为4个空格?
你的问题到底是什么?缩进如何打破? – cschol 2008-09-15 17:53:01
你在使用什么平台? Windows/Mac的/ Linux呢? – Jamie 2008-09-15 20:54:29